##// END OF EJS Templates
Make compression more intelligent:...
mpm@selenic.com -
r112:aea6562a default
parent child Browse files
Show More
@@ -16,10 +16,23 b' def bin(node): return binascii.unhexlify'
16 def short(node): return hex(node[:4])
16 def short(node): return hex(node[:4])
17
17
18 def compress(text):
18 def compress(text):
19 return zlib.compress(text)
19 if not text: return text
20 if len(text) < 44:
21 if text[0] == '\0': return text
22 return 'u' + text
23 bin = zlib.compress(text)
24 if len(bin) > len(text):
25 if text[0] == '\0': return text
26 return 'u' + text
27 return bin
20
28
21 def decompress(bin):
29 def decompress(bin):
22 return zlib.decompress(bin)
30 if not bin: return bin
31 t = bin[0]
32 if t == '\0': return bin
33 if t == 'x': return zlib.decompress(bin)
34 if t == 'u': return bin[1:]
35 raise "unknown compression type %s" % t
23
36
24 def hash(text, p1, p2):
37 def hash(text, p1, p2):
25 l = [p1, p2]
38 l = [p1, p2]
General Comments 0
You need to be logged in to leave comments. Login now