diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/fileutils.rb | 8 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 10 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Sat Feb 25 17:10:51 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/fileutils.rb: use chomp(?/) instead of sub to optimize and avoid + to regexping invalid string. + Sat Feb 25 17:09:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * dir.c (dir_inspect), io.c (rb_io_inspect): keep encoding of path. diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 29cb2354c1..ee396e35cb 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -202,7 +202,7 @@ module FileUtils fu_output_message "mkdir -p #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose] return *list if options[:noop] - list.map {|path| path.sub(%r</\z>, '') }.each do |path| + list.map {|path| path.chomp(?/) }.each do |path| # optimize for the most common case begin fu_mkdir path, options[:mode] @@ -239,7 +239,7 @@ module FileUtils OPT_TABLE['makedirs'] = [:mode, :noop, :verbose] def fu_mkdir(path, mode) #:nodoc: - path = path.sub(%r</\z>, '') + path = path.chomp(?/) if mode Dir.mkdir path, mode File.chmod mode, path @@ -267,7 +267,7 @@ module FileUtils return if options[:noop] list.each do |dir| begin - Dir.rmdir(dir = dir.sub(%r</\z>, '')) + Dir.rmdir(dir = dir.chomp(?/)) if parents until (parent = File.dirname(dir)) == '.' or parent == dir Dir.rmdir(dir) @@ -1397,7 +1397,7 @@ module FileUtils def remove_dir1 platform_support { - Dir.rmdir path().sub(%r</\z>, '') + Dir.rmdir path().chomp(?/) } end @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 145 +#define RUBY_PATCHLEVEL 146 #define RUBY_RELEASE_DATE "2012-02-25" #define RUBY_RELEASE_YEAR 2012 |