From 35cfd9334d381d06e8a5364a2eaa4b7b8d7b0bbc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 20 Oct 2013 07:38:41 -0400 Subject: Now I can use collections.defaultdict --HG-- branch : 4.0 --- coverage/parser.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'coverage/parser.py') diff --git a/coverage/parser.py b/coverage/parser.py index 010cd73a..6332f637 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -1,6 +1,6 @@ """Code parsing for Coverage.""" -import dis, re, sys, token, tokenize +import collections, dis, re, sys, token, tokenize from coverage.backward import StringIO from coverage.backward import open_source, range # pylint: disable=W0622 @@ -242,7 +242,7 @@ class CodeParser(object): """ excluded_lines = self.first_lines(self.excluded) - exit_counts = {} + exit_counts = collections.defaultdict(int) for l1, l2 in self.arcs(): if l1 < 0: # Don't ever report -1 as a line number @@ -253,8 +253,6 @@ class CodeParser(object): if l2 in excluded_lines: # Arcs to excluded lines shouldn't count. continue - if l1 not in exit_counts: - exit_counts[l1] = 0 exit_counts[l1] += 1 # Class definitions have one extra exit, so remove one for each: -- cgit v1.2.1