Skip to content

Commit c96b559

Browse files
committed
Optimize Pathname#initialize to avoid extra ivar accesses
1 parent aa4d4c6 commit c96b559

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/pathname.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ class Pathname
236236
#
237237
def initialize(path)
238238
path = path.to_path if path.respond_to? :to_path
239-
@path = path.dup
240-
241-
if /\0/.match?(@path)
242-
raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
239+
if /\0/.match?(path)
240+
raise ArgumentError, "pathname contains \\0: #{path.inspect}"
243241
end
242+
243+
@path = path.dup
244244
end
245245

246246
def freeze() super; @path.freeze; self end

0 commit comments

Comments
 (0)