From 41542767d2aae4a5ab5962a021eaa2619becb0ea Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 3 May 2026 21:01:43 +0900 Subject: pathname: Reuse dirname results --- pathname_builtin.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pathname_builtin.rb b/pathname_builtin.rb index 4bd8b002f3..84b2bf2848 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -299,9 +299,9 @@ class Pathname path = @path == '/' ? @path : @path.chomp('/') stack = [] - until File.directory?(path) || File.dirname(path) == path + until File.directory?(path) || (parent = File.dirname(path)) == path stack.push path - path = File.dirname(path) + path = parent end stack.reverse_each do |dir| -- cgit v1.2.3