Skip to content

Commit ca3432c

Browse files
committed
pathname: Reuse dirname results
1 parent 1728254 commit ca3432c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

pathname_builtin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ def mkpath(mode: nil)
299299
path = @path == '/' ? @path : @path.chomp('/')
300300

301301
stack = []
302-
until File.directory?(path) || File.dirname(path) == path
302+
until File.directory?(path) || (parent = File.dirname(path)) == path
303303
stack.push path
304-
path = File.dirname(path)
304+
path = parent
305305
end
306306

307307
stack.reverse_each do |dir|

0 commit comments

Comments
 (0)