# HG changeset patch # User Siddharth Agarwal # Date 1414920874 28800 # Node ID d07ccad28b1a8f8fdef4144812e1b9af75ac7f6b # Parent c54214bb6c4e24d00f02bc7597c85bfecbce40cc maps.RevMap: avoid O(revs) property lookups on dict Loading a million-entry revmap goes from 3.72 seconds to 3.65. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -224,6 +224,7 @@ class RevMap(dict): def _load(self): lastpulled = self.meta.lastpulled firstpulled = self.meta.firstpulled + setitem = dict.__setitem__ for l in self.readmapfile(self.meta.revmap_file): revnum, ha, branch = l.split(' ', 2) if branch == '\n': @@ -235,7 +236,7 @@ class RevMap(dict): lastpulled = revnum if revnum < firstpulled or not firstpulled: firstpulled = revnum - dict.__setitem__(self, (revnum, branch), bin(ha)) + setitem(self, (revnum, branch), bin(ha)) self.meta.lastpulled = lastpulled self.meta.firstpulled = firstpulled