Skip to content

Commit d8c665c

Browse files
committed
Dir.children is available since Feature #11302. FileUtils uses
Dir.each on an internal method encapsulated on a private class `Entry_#entry`, having no '.' neither '..' entries would make now superfluous a chained reject filtering. This change can improve the performance of these FileUtils methods when the provided path covers thousands of files or directories: - chmod_R - chown_R - remove_entry - remove_entry_secure - rm_r - remove_dir - copy_entry Related: Feature #13896 https://bugs.ruby-lang.org/issues/13896 [Feature #14109][Fix GH-1754] Co-Authored-By: esparta <[email protected]> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent d911f14 commit d8c665c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/fileutils.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,8 +1274,7 @@ def door?
12741274
def entries
12751275
opts = {}
12761276
opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
1277-
Dir.entries(path(), opts)\
1278-
.reject {|n| n == '.' or n == '..' }\
1277+
Dir.children(path, opts)\
12791278
.map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }
12801279
end
12811280

0 commit comments

Comments
 (0)