##// 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,6 +51,13 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 """
54 # As of now, if one of the parent node is null, p2 is null
55 if p2 == nullid:
56 # deep copy of a hash is faster than creating one
57 s = nullhash.copy()
58 s.update(p1)
59 else:
60 # none of the parent nodes are nullid
52 l = [p1, p2]
61 l = [p1, p2]
53 l.sort()
62 l.sort()
54 s = _sha(l[0])
63 s = _sha(l[0])
General Comments 0
You need to be logged in to leave comments. Login now