ruby-changes:62965
From: Ashwin <ko1@a...>
Date: Tue, 15 Sep 2020 20:49:03 +0900 (JST)
Subject: [ruby-changes:62965] 3dd9e12b51 (master): [ruby/fileutils] Reduce iteration through list for `:mkdir_p`
https://git.ruby-lang.org/ruby.git/commit/?id=3dd9e12b51 From 3dd9e12b515dea2c8a14b33c762807bb54625aef Mon Sep 17 00:00:00 2001 From: Ashwin Maroli <ashmaroli@u...> Date: Thu, 10 Sep 2020 23:28:35 +0530 Subject: [ruby/fileutils] Reduce iteration through list for `:mkdir_p` By calling the instruction to `list.map` within `list.each` itself. https://github.com/ruby/fileutils/commit/e690eec937 diff --git a/lib/fileutils.rb b/lib/fileutils.rb index c8f4b49..179d764 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -208,7 +208,9 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L208 fu_output_message "mkdir -p #{mode ? ('-m %03o ' % mode) : ''}#{list.join ' '}" if verbose return *list if noop - list.map {|path| remove_trailing_slash(path)}.each do |path| + list.each do |item| + path = remove_trailing_slash(item) + # optimize for the most common case begin fu_mkdir path, mode -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/