Skip to content

Commit 643585a

Browse files
committed
Use Regexp#match? instead of =~ for better performance
* Avoids a MatchData allocation.
1 parent fe027ae commit 643585a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/pathname.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def initialize(path)
233233
path = path.__send__(TO_PATH) if path.respond_to? TO_PATH
234234
@path = path.dup
235235

236-
if /\0/ =~ @path
236+
if /\0/.match?(@path)
237237
raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
238238
end
239239
end

0 commit comments

Comments
 (0)