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 | 7d23342011606460e5a22f189814702efa95d690 (patch) | |
tree | 67b42a1b7d08906d5d692a5e01238d72949158df /coverage/parser.py | |
parent | da6cee398eec22d52fe18072931ebcd68e904aa2 (diff) | |
download | python-coveragepy-7d23342011606460e5a22f189814702efa95d690.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 ed8f379..7a145a2 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 |