diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-06-05 18:52:04 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-06-05 19:39:29 -0400 |
commit | b1c079ed5b5f0ccf8ed81fbc354418709ff6269d (patch) | |
tree | 66eff03485958cfa92ff015af98a8a1198af3461 /coverage/parser.py | |
parent | 69e9a61f28853e2e79f9711b97b7ce4f57e834ed (diff) | |
download | python-coveragepy-git-b1c079ed5b5f0ccf8ed81fbc354418709ff6269d.tar.gz |
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.
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 13 |
1 files changed, 3 insertions, 10 deletions
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 |