##// END OF EJS Templates
chunkiter: handle large reads more efficiently...
Matt Mackall -
r5449:17a4b20e default
parent child Browse files
Show More
@@ -1408,7 +1408,7 b' class chunkbuffer(object):'
1408 Returns less than L bytes if the iterator runs dry."""
1408 Returns less than L bytes if the iterator runs dry."""
1409 if l > len(self.buf) and self.iter:
1409 if l > len(self.buf) and self.iter:
1410 # Clamp to a multiple of self.targetsize
1410 # Clamp to a multiple of self.targetsize
1411 targetsize = self.targetsize * ((l // self.targetsize) + 1)
1411 targetsize = max(l, self.targetsize)
1412 collector = cStringIO.StringIO()
1412 collector = cStringIO.StringIO()
1413 collector.write(self.buf)
1413 collector.write(self.buf)
1414 collected = len(self.buf)
1414 collected = len(self.buf)
@@ -1420,7 +1420,10 b' class chunkbuffer(object):'
1420 if collected < targetsize:
1420 if collected < targetsize:
1421 self.iter = False
1421 self.iter = False
1422 self.buf = collector.getvalue()
1422 self.buf = collector.getvalue()
1423 s, self.buf = self.buf[:l], buffer(self.buf, l)
1423 if len(self.buf) == l:
1424 s, self.buf = self.buf, ''
1425 else:
1426 s, self.buf = self.buf[:l], buffer(self.buf, l)
1424 return s
1427 return s
1425
1428
1426 def filechunkiter(f, size=65536, limit=None):
1429 def filechunkiter(f, size=65536, limit=None):
General Comments 0
You need to be logged in to leave comments. Login now