diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-07 15:55:14 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-07 15:55:14 +0000 |
commit | 37c08fad04eb021cf56eb0d190092bd07e19fad8 (patch) | |
tree | 48f7ff14c66da4dbdf38b0a0bd9d7afa3a3a4c50 /lib/fileutils.rb | |
parent | 8c56aa51b5f7655198b5ecc4a03a9b7b5de88ff5 (diff) |
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 <esparta@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r-- | lib/fileutils.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 74b21975e3..dc7261857b 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -1274,8 +1274,7 @@ module FileUtils def entries opts = {} opts[:encoding] = ::Encoding::UTF_8 if fu_windows? - Dir.entries(path(), opts)\ - .reject {|n| n == '.' or n == '..' }\ + Dir.children(path, opts)\ .map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) } end |