Mercurial > hg > hg-git
diff hggit/git_handler.py @ 877:b250e7b3ad71
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.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Thu, 09 Apr 2015 20:14:33 -0700 |
parents | 8c112b6d5e61 |
children | be105c4dda7b |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -173,7 +173,13 @@ 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