Mercurial > hg > mercurial-source
changeset 23816:e880036719e3
readmarkers: fast-path single successors and parents
This gives about a 5% performance bump.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 11 Jan 2015 16:37:57 -0600 |
parents | 2763edaba857 |
children | 345042e024dc |
files | mercurial/obsolete.py |
diffstat | 1 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -308,25 +308,39 @@ if flags & sha2flag: # read 0 or more successors - o2 = o1 + sha2size * numsuc - sucs = unpack(sha2fmt * numsuc, data[o1:o2]) + if numsuc == 1: + o2 = o1 + sha2size + sucs = (data[o1:o2],) + else: + o2 = o1 + sha2size * numsuc + sucs = unpack(sha2fmt * numsuc, data[o1:o2]) # read parents if numpar == noneflag: o3 = o2 parents = None + elif numpar == 1: + o3 = o2 + sha2size + parents = (data[o2:o3],) else: o3 = o2 + sha2size * numpar parents = unpack(sha2fmt * numpar, data[o2:o3]) else: # read 0 or more successors - o2 = o1 + sha1size * numsuc - sucs = unpack(sha1fmt * numsuc, data[o1:o2]) + if numsuc == 1: + o2 = o1 + sha1size + sucs = (data[o1:o2],) + else: + o2 = o1 + sha1size * numsuc + sucs = unpack(sha1fmt * numsuc, data[o1:o2]) # read parents if numpar == noneflag: o3 = o2 parents = None + elif numpar == 1: + o3 = o2 + sha1size + parents = (data[o2:o3],) else: o3 = o2 + sha1size * numpar parents = unpack(sha1fmt * numpar, data[o2:o3])