git_handler.load_map: avoid split and strip

For a mapfile with 1.5 million entries, this speeds up load_map from 2.3
seconds to 1.8.
This commit is contained in:
Siddharth Agarwal 2015-04-09 20:14:33 -07:00
parent 6e87e0e982
commit 1a15adc3e0

View File

@ -173,7 +173,13 @@ class GitHandler(object):
map_hg_real = {}
if os.path.exists(self.repo.join(self.map_file)):
for line in self.repo.opener(self.map_file):
gitsha, hgsha = line.strip().split(' ', 1)
# format is <40 hex digits> <40 hex digits>\n
if len(line) != 82:
raise ValueError(
_('corrupt mapfile: incorrect line length %d') %
len(line))
gitsha = line[:40]
hgsha = line[41:81]
map_git_real[gitsha] = hgsha
map_hg_real[hgsha] = gitsha
self._map_git_real = map_git_real