[PATCH 6 of 6 V2] obsstore: cache size computation for fm1 node

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Dec 4 09:16:19 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1417073013 28800
#      Wed Nov 26 23:23:33 2014 -0800
# Node ID 6289daa98b37da9e9948db4f8fdda17b0a0f507b
# Parent  786d60c87bc62b1e5ce5c479d9ebc3973f6b3fa3
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.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -274,10 +274,12 @@ def _fm0decodemeta(data):
 # - remaining bytes: the metadata, each (key, value) pair after the other.
 _fm1version = 1
 _fm1fixed = '>IdhHBBB20s'
 _fm1nodesha1 = '20s'
 _fm1nodesha256 = '32s'
+_fm1nodesha1size = _calcsize(_fm1nodesha1)
+_fm1nodesha256size = _calcsize(_fm1nodesha256)
 _fm1fsize = _calcsize(_fm1fixed)
 _fm1parentnone = 3
 _fm1parentshift = 14
 _fm1parentmask = (_fm1parentnone << _fm1parentshift)
 _fm1metapair = 'BB'
@@ -296,13 +298,14 @@ def _fm1readmarkers(data, off=0):
         if numpar == _fm1parentnone:
             numpar = None
         # build the date tuple (upgrade tz minutes to seconds)
         date = (seconds, tz * 60)
         _fm1node = _fm1nodesha1
+        fnodesize = _fm1nodesha1size
         if flags & usingsha256:
             _fm1node = _fm1nodesha256
-        fnodesize = _calcsize(_fm1node)
+            fnodesize = _fm1nodesha256size
         # read replacement
         sucs = ()
         if numsuc:
             s = (fnodesize * numsuc)
             cur = data[off:off + s]


More information about the Mercurial-devel mailing list