Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.py @ 11670:1b3b843e1100
chunkbuffer: split big strings directly in chunkbuffer
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 25 Jul 2010 13:10:57 +0200 |
parents | f070d284994c |
children | 05deba16c5d5 |
line wrap: on
line diff
--- a/mercurial/util.py Sun Jul 25 10:05:38 2010 +0900 +++ b/mercurial/util.py Sun Jul 25 13:10:57 2010 +0200 @@ -914,7 +914,17 @@ def __init__(self, in_iter): """in_iter is the iterator that's iterating over the input chunks. targetsize is how big a buffer to try to maintain.""" - self.iter = iter(in_iter) + def splitbig(chunks): + for chunk in chunks: + if len(chunk) > 2**20: + pos = 0 + while pos < len(chunk): + end = pos + 2 ** 18 + yield chunk[pos:end] + pos = end + else: + yield chunk + self.iter = splitbig(in_iter) self.buf = '' def read(self, l):