Skip to content

Commit 468aa22

Browse files
committed
refactor: no need to compile a regex used once
1 parent bfb0c70 commit 468aa22

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

coverage/parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ def lines_matching(self, regex: str) -> set[TLineNo]:
109109
Handles multiline regex patterns.
110110
111111
"""
112-
regex_c = re.compile(regex, re.MULTILINE)
113112
matches: set[TLineNo] = set()
114113

115114
last_start = 0
116115
last_start_line = 0
117-
for match in regex_c.finditer(self.text):
116+
for match in re.finditer(regex, self.text, flags=re.MULTILINE):
118117
start, end = match.span()
119118
start_line = last_start_line + self.text.count('\n', last_start, start)
120119
end_line = last_start_line + self.text.count('\n', last_start, end)

0 commit comments

Comments
 (0)