From 7d23342011606460e5a22f189814702efa95d690 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 27 Oct 2013 09:06:41 -0400 Subject: ByteCodes.__iter__ is expensive, do it once instead of twice. --- coverage/parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'coverage/parser.py') 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 -- cgit v1.2.1