* lib/fileutils.rb: use chomp(?/) instead of sub to optimize and avoid

to regexping invalid string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-02-25 08:08:55 +00:00
Родитель 9167535c50
Коммит 9a93699a49
2 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sat Feb 25 17:07:15 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 16:18:24 2012 NARUSE, Yui <naruse@ruby-lang.org>
* complex.c (nucomp_marshal_load): raise error on invalid data.

Просмотреть файл

@ -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</\z>, '') }.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</\z>, '')
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</\z>, ''))
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</\z>, '')
Dir.rmdir path().chomp(?/)
}
end