diff --git a/ChangeLog b/ChangeLog index a31a61218f..dbdaed4b28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 25 17:07:15 2012 NARUSE, Yui + + * lib/fileutils.rb: use chomp(?/) instead of sub to optimize and avoid + to regexping invalid string. + Sat Feb 25 16:18:24 2012 NARUSE, Yui * complex.c (nucomp_marshal_load): raise error on invalid data. diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 46dfffb650..6f8add067a 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -281,7 +281,7 @@ public 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, '') }.each do |path| + list.map {|path| path.chomp(?/) }.each do |path| # optimize for the most common case begin fu_mkdir path, options[:mode] @@ -317,7 +317,7 @@ public private def fu_mkdir(path, mode) #:nodoc: - path = path.sub(%r, '') + path = path.chomp(?/) if mode Dir.mkdir path, mode File.chmod mode, path @@ -346,7 +346,7 @@ public return if options[:noop] list.each do |dir| begin - Dir.rmdir(dir = dir.sub(%r, '')) + Dir.rmdir(dir = dir.chomp(?/)) if parents until (parent = File.dirname(dir)) == '.' or parent == dir Dir.rmdir(dir) @@ -1465,7 +1465,7 @@ private def remove_dir1 platform_support { - Dir.rmdir path().sub(%r, '') + Dir.rmdir path().chomp(?/) } end