From b1c079ed5b5f0ccf8ed81fbc354418709ff6269d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 5 Jun 2021 18:52:04 -0400 Subject: refactor: no need for clever byte_parser property It was only ever used once per object, so just make the ByteParser when we need it. --- coverage/parser.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'coverage/parser.py') diff --git a/coverage/parser.py b/coverage/parser.py index 1c6e995a..1c8ecc3e 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -82,18 +82,10 @@ class PythonParser: # multi-line statements. self._multiline = {} - # Lazily-created ByteParser, arc data, and missing arc descriptions. - self._byte_parser = None + # Lazily-created arc data, and missing arc descriptions. self._all_arcs = None self._missing_arc_fragments = None - @property - def byte_parser(self): - """Create a ByteParser on demand.""" - if not self._byte_parser: - self._byte_parser = ByteParser(self.text, filename=self.filename) - return self._byte_parser - def lines_matching(self, *regexes): """Find the lines matching one of a list of regexes. @@ -199,7 +191,8 @@ class PythonParser: # Find the starts of the executable statements. if not empty: - self.raw_statements.update(self.byte_parser._find_statements()) + byte_parser = ByteParser(self.text, filename=self.filename) + self.raw_statements.update(byte_parser._find_statements()) # The first line of modules can lie and say 1 always, even if the first # line of code is later. If so, map 1 to the actual first line of the -- cgit v1.2.1