##// END OF EJS Templates
revlog: break up compression of large deltas...
Matt Mackall -
r5451:0a438756 default
parent child Browse files
Show More
@@ -61,12 +61,27 b' def compress(text):'
61 61 """ generate a possibly-compressed representation of text """
62 62 if not text:
63 63 return ("", text)
64 if len(text) < 44:
64 l = len(text)
65 if l < 44:
65 66 if text[0] == '\0':
66 67 return ("", text)
67 68 return ('u', text)
68 bin = _compress(text)
69 if len(bin) > len(text):
69 elif l > 1000000:
70 # zlib makes an internal copy, thus doubling memory usage for
71 # large files, so lets do this in pieces
72 z = zlib.compressobj()
73 p = []
74 pos = 0
75 while pos < l:
76 pos2 = pos + 2**20
77 p.append(z.compress(text[pos:pos2]))
78 pos = pos2
79 p.append(z.flush())
80 if sum(map(len, p)) < l:
81 bin = "".join(p)
82 else:
83 bin = _compress(text)
84 if len(bin) > l:
70 85 if text[0] == '\0':
71 86 return ("", text)
72 87 return ('u', text)
General Comments 0
You need to be logged in to leave comments. Login now