Skip to content

Commit e68043d

Browse files
splattaelPragTob
authored andcommitted
Improve performance of lines classifier
Prefer `Regexp#match?` over `String#=~` which improves the speed by ~50% for these methods.
1 parent 70bc4b7 commit e68043d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/simplecov/lines_classifier.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ def self.no_cov_line
1717
end
1818

1919
def self.no_cov_line?(line)
20-
line =~ no_cov_line
20+
no_cov_line.match?(line)
2121
rescue ArgumentError
2222
# E.g., line contains an invalid byte sequence in UTF-8
2323
false
2424
end
2525

2626
def self.whitespace_line?(line)
27-
line =~ WHITESPACE_OR_COMMENT_LINE
27+
WHITESPACE_OR_COMMENT_LINE.match?(line)
2828
rescue ArgumentError
2929
# E.g., line contains an invalid byte sequence in UTF-8
3030
false

0 commit comments

Comments
 (0)