Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 33391:943b8c37f49d
revlog: micro-optimize the computation of hashes
Differential Revision: https://phab.mercurial-scm.org/D31
author | Alex Gaynor <agaynor@mozilla.com> |
---|---|
date | Mon, 10 Jul 2017 16:39:28 -0400 |
parents | 85d1ac011582 |
children | ac6446611ad2 |
comparison
equal
deleted
inserted
replaced
33390:32331f54930c | 33391:943b8c37f49d |
---|---|
150 # deep copy of a hash is faster than creating one | 150 # deep copy of a hash is faster than creating one |
151 s = _nullhash.copy() | 151 s = _nullhash.copy() |
152 s.update(p1) | 152 s.update(p1) |
153 else: | 153 else: |
154 # none of the parent nodes are nullid | 154 # none of the parent nodes are nullid |
155 l = [p1, p2] | 155 if p1 < p2: |
156 l.sort() | 156 a = p1 |
157 s = hashlib.sha1(l[0]) | 157 b = p2 |
158 s.update(l[1]) | 158 else: |
159 a = p2 | |
160 b = p1 | |
161 s = hashlib.sha1(a) | |
162 s.update(b) | |
159 s.update(text) | 163 s.update(text) |
160 return s.digest() | 164 return s.digest() |
161 | 165 |
162 # index v0: | 166 # index v0: |
163 # 4 bytes: offset | 167 # 4 bytes: offset |