comparison mercurial/util.py @ 11668:f070d284994c

chunkbuffer: targetsize isn't used outside of read()
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 24 Jul 2010 17:23:08 +0200
parents 78d1e92ba1c0
children 1b3b843e1100
comparison
equal deleted inserted replaced
11667:78d1e92ba1c0 11668:f070d284994c
914 def __init__(self, in_iter): 914 def __init__(self, in_iter):
915 """in_iter is the iterator that's iterating over the input chunks. 915 """in_iter is the iterator that's iterating over the input chunks.
916 targetsize is how big a buffer to try to maintain.""" 916 targetsize is how big a buffer to try to maintain."""
917 self.iter = iter(in_iter) 917 self.iter = iter(in_iter)
918 self.buf = '' 918 self.buf = ''
919 self.targetsize = 2**16
920 919
921 def read(self, l): 920 def read(self, l):
922 """Read L bytes of data from the iterator of chunks of data. 921 """Read L bytes of data from the iterator of chunks of data.
923 Returns less than L bytes if the iterator runs dry.""" 922 Returns less than L bytes if the iterator runs dry."""
924 if l > len(self.buf) and self.iter: 923 if l > len(self.buf) and self.iter:
925 # Clamp to a multiple of self.targetsize 924 # Clamp to a multiple of 2**16
926 targetsize = max(l, self.targetsize) 925 targetsize = max(l, 2**16)
927 collector = [str(self.buf)] 926 collector = [str(self.buf)]
928 collected = len(self.buf) 927 collected = len(self.buf)
929 for chunk in self.iter: 928 for chunk in self.iter:
930 collector.append(chunk) 929 collector.append(chunk)
931 collected += len(chunk) 930 collected += len(chunk)