Skip to content

Commit cb0e7f4

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

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/pathname.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def initialize(path)
215215
path = path.__send__(TO_PATH) if path.respond_to? TO_PATH
216216
@path = path.dup
217217

218-
if /\0/ =~ @path
218+
if /\0/.match?(@path)
219219
raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
220220
end
221221
end

0 commit comments

Comments
 (0)