Skip to content

Commit e690eec

Browse files
ashmarolijeremyevans
authored andcommitted
Reduce iteration through list for :mkdir_p
By calling the instruction to `list.map` within `list.each` itself.
1 parent 1bbf564 commit e690eec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/fileutils.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ def mkdir_p(list, mode: nil, noop: nil, verbose: nil)
208208
fu_output_message "mkdir -p #{mode ? ('-m %03o ' % mode) : ''}#{list.join ' '}" if verbose
209209
return *list if noop
210210

211-
list.map {|path| remove_trailing_slash(path)}.each do |path|
211+
list.each do |item|
212+
path = remove_trailing_slash(item)
213+
212214
# optimize for the most common case
213215
begin
214216
fu_mkdir path, mode

0 commit comments

Comments
 (0)