diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-27 09:06:41 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-27 09:06:41 -0400 |
commit | a9656f81e6d97184766faf3ca84d00df86338339 (patch) | |
tree | fab989d72a4774e0c9da831d0ebe54a0e6cdf952 /coverage/parser.py | |
parent | 1c8f5bbc976d521b9d0cf5b68d404a5315e02c39 (diff) | |
download | python-coveragepy-git-a9656f81e6d97184766faf3ca84d00df86338339.tar.gz |
ByteCodes.__iter__ is expensive, do it once instead of twice.
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index ed8f3793..7a145a2a 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -449,14 +449,15 @@ class ByteParser(object): # Get a set of all of the jump-to points. jump_to = set() - for bc in ByteCodes(self.code.co_code): + bytecodes = list(ByteCodes(self.code.co_code)) + for bc in bytecodes: if bc.jump_to >= 0: jump_to.add(bc.jump_to) chunk_lineno = 0 # Walk the byte codes building chunks. - for bc in ByteCodes(self.code.co_code): + for bc in bytecodes: # Maybe have to start a new chunk start_new_chunk = False first_chunk = False |