##// END OF EJS Templates
revlog: faster hash computation when one of the parent node is null...
Nicolas Dumazet -
r7883:c63c30ae default
parent child Browse files
Show More
@@ -42,6 +42,8 b' def gettype(q):'
42 def offset_type(offset, type):
42 def offset_type(offset, type):
43 return long(long(offset) << 16 | type)
43 return long(long(offset) << 16 | type)
44
44
45 nullhash = _sha(nullid)
46
45 def hash(text, p1, p2):
47 def hash(text, p1, p2):
46 """generate a hash from the given text and its parent hashes
48 """generate a hash from the given text and its parent hashes
47
49
@@ -49,10 +51,17 b' def hash(text, p1, p2):'
49 in a manner that makes it easy to distinguish nodes with the same
51 in a manner that makes it easy to distinguish nodes with the same
50 content in the revision graph.
52 content in the revision graph.
51 """
53 """
52 l = [p1, p2]
54 # As of now, if one of the parent node is null, p2 is null
53 l.sort()
55 if p2 == nullid:
54 s = _sha(l[0])
56 # deep copy of a hash is faster than creating one
55 s.update(l[1])
57 s = nullhash.copy()
58 s.update(p1)
59 else:
60 # none of the parent nodes are nullid
61 l = [p1, p2]
62 l.sort()
63 s = _sha(l[0])
64 s.update(l[1])
56 s.update(text)
65 s.update(text)
57 return s.digest()
66 return s.digest()
58
67
General Comments 0
You need to be logged in to leave comments. Login now