Issue #3608 has been updated by mame (Yusuke Endoh).

Description updated
Target version set to next minor


----------------------------------------
Feature #3608: Enhancing Pathname#each_child to be lazy
https://bugs.ruby-lang.org/issues/3608#change-33226

Author: taw (Tomasz Wegrzanowski)
Status: Assigned
Priority: Normal
Assignee: akr (Akira Tanaka)
Category: 
Target version: next minor


=begin
 Right now it lists entire directory, then yields
 every element, that is x.each_child(&b) means x.children.each(&b).
 
 This is too slow for directories mounted over networked file systems etc.,
 and there is currently no way to get lazy behaviour, other than leaving
 convenient #each_child/#children API and moving to lower level.
 
 With this patch:
 * #children is eager like before, no change here
 * #each_child becomes lazy
 * #each_child without block returns lazy enumerator,
   so it can be used like this dir.each_child.find(&:symlink?)
   without losing laziness.
 
 Patch is against trunk. pathname.rb was in lib/ not ext/pathname/lib/
 before, but it works either way.
 
 The part to return enumerator when called without a block wouldn't
 work in 1.8. If backport is desired, that line would need to be thrown
 away, and #children would need to build result array instead
 of calling each_child(with_directory).to_a - this would be straightforward.
=end



-- 
http://bugs.ruby-lang.org/