Mercurial > public > mercurial-scm > hg
comparison mercurial/obsolete.py @ 23499:b46876c94a93
obsstore: cache size computation for fm1 node
We have two different types of node type (sha1 and sha256, only sha1 is used
now) and therefor different sizes for them. We now compute the value once
instead of redoing the computation every loop. This has no visible performance
impact.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 26 Nov 2014 23:23:33 -0800 |
parents | ac910b1f5658 |
children | 48284b8f6073 |
comparison
equal
deleted
inserted
replaced
23498:ac910b1f5658 | 23499:b46876c94a93 |
---|---|
274 # - remaining bytes: the metadata, each (key, value) pair after the other. | 274 # - remaining bytes: the metadata, each (key, value) pair after the other. |
275 _fm1version = 1 | 275 _fm1version = 1 |
276 _fm1fixed = '>IdhHBBB20s' | 276 _fm1fixed = '>IdhHBBB20s' |
277 _fm1nodesha1 = '20s' | 277 _fm1nodesha1 = '20s' |
278 _fm1nodesha256 = '32s' | 278 _fm1nodesha256 = '32s' |
279 _fm1nodesha1size = _calcsize(_fm1nodesha1) | |
280 _fm1nodesha256size = _calcsize(_fm1nodesha256) | |
279 _fm1fsize = _calcsize(_fm1fixed) | 281 _fm1fsize = _calcsize(_fm1fixed) |
280 _fm1parentnone = 3 | 282 _fm1parentnone = 3 |
281 _fm1parentshift = 14 | 283 _fm1parentshift = 14 |
282 _fm1parentmask = (_fm1parentnone << _fm1parentshift) | 284 _fm1parentmask = (_fm1parentnone << _fm1parentshift) |
283 _fm1metapair = 'BB' | 285 _fm1metapair = 'BB' |
296 if numpar == _fm1parentnone: | 298 if numpar == _fm1parentnone: |
297 numpar = None | 299 numpar = None |
298 # build the date tuple (upgrade tz minutes to seconds) | 300 # build the date tuple (upgrade tz minutes to seconds) |
299 date = (seconds, tz * 60) | 301 date = (seconds, tz * 60) |
300 _fm1node = _fm1nodesha1 | 302 _fm1node = _fm1nodesha1 |
303 fnodesize = _fm1nodesha1size | |
301 if flags & usingsha256: | 304 if flags & usingsha256: |
302 _fm1node = _fm1nodesha256 | 305 _fm1node = _fm1nodesha256 |
303 fnodesize = _calcsize(_fm1node) | 306 fnodesize = _fm1nodesha256size |
304 # read replacement | 307 # read replacement |
305 sucs = () | 308 sucs = () |
306 if numsuc: | 309 if numsuc: |
307 s = (fnodesize * numsuc) | 310 s = (fnodesize * numsuc) |
308 cur = data[off:off + s] | 311 cur = data[off:off + s] |