Mercurial > hg
changeset 23798:86d2a0c41f44
readmarkers: streamline offset tracking
This minimizes the number of assignments and operations needed to use offsets.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 11 Jan 2015 14:43:31 -0600 |
parents | eb12c3cf210c |
children | ffca0a14b566 |
files | mercurial/obsolete.py |
diffstat | 1 files changed, 13 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/obsolete.py Sun Jan 11 14:37:50 2015 -0600 +++ b/mercurial/obsolete.py Sun Jan 11 14:43:31 2015 -0600 @@ -291,8 +291,8 @@ ufixed = util.unpacker(_fm1fixed) while off + _fm1fsize <= l: # read fixed part - fixeddata = ufixed(data[off:off + _fm1fsize]) - off += _fm1fsize + o1 = off + _fm1fsize + fixeddata = ufixed(data[off:o1]) ttsize, seconds, tz, flags, numsuc, numpar, nummeta, prec = fixeddata _fm1node = _fm1nodesha1 @@ -302,29 +302,27 @@ fnodesize = _fm1nodesha256size # read 0 or more successors - s = (fnodesize * numsuc) - sucs = _unpack(_fm1node * numsuc, data[off:off + s]) - off += s + o2 = o1 + fnodesize * numsuc + sucs = _unpack(_fm1node * numsuc, data[o1:o2]) # read parents if numpar == _fm1parentnone: + o3 = o2 parents = None else: - s = (fnodesize * numpar) - parents = _unpack(_fm1node * numpar, data[off:off + s]) - off += s + o3 = o2 + fnodesize * numpar + parents = _unpack(_fm1node * numpar, data[o2:o3]) # read metadata metaformat = '>' + (_fm1metapair * nummeta) - s = _fm1metapairsize * nummeta - metapairsize = _unpack(metaformat, data[off:off + s]) - off += s + off = o3 + _fm1metapairsize * nummeta + metapairsize = _unpack(metaformat, data[o3:off]) metadata = [] for idx in xrange(0, len(metapairsize), 2): - sk = metapairsize[idx] - sv = metapairsize[idx + 1] - metadata.append((data[off:off + sk], data[off + sk:off + sk + sv])) - off += sk + sv + o1 = off + metapairsize[idx] + o2 = o1 + metapairsize[idx + 1] + metadata.append((data[off:o1], data[o1:o2])) + off = o2 yield (prec, sucs, flags, tuple(metadata), (seconds, tz * 60), parents)