##// END OF EJS Templates
chunkbuffer: use list instead of cStringIO
Benoit Boissinot -
r11667:78d1e92b default
parent child Browse files
Show More
@@ -15,7 +15,7 b' hide platform-specific details from the '
15
15
16 from i18n import _
16 from i18n import _
17 import error, osutil, encoding
17 import error, osutil, encoding
18 import cStringIO, errno, re, shutil, sys, tempfile, traceback
18 import errno, re, shutil, sys, tempfile, traceback
19 import os, stat, time, calendar, textwrap, unicodedata, signal
19 import os, stat, time, calendar, textwrap, unicodedata, signal
20 import imp
20 import imp
21
21
@@ -924,17 +924,16 b' class chunkbuffer(object):'
924 if l > len(self.buf) and self.iter:
924 if l > len(self.buf) and self.iter:
925 # Clamp to a multiple of self.targetsize
925 # Clamp to a multiple of self.targetsize
926 targetsize = max(l, self.targetsize)
926 targetsize = max(l, self.targetsize)
927 collector = cStringIO.StringIO()
927 collector = [str(self.buf)]
928 collector.write(self.buf)
929 collected = len(self.buf)
928 collected = len(self.buf)
930 for chunk in self.iter:
929 for chunk in self.iter:
931 collector.write(chunk)
930 collector.append(chunk)
932 collected += len(chunk)
931 collected += len(chunk)
933 if collected >= targetsize:
932 if collected >= targetsize:
934 break
933 break
935 else:
934 else:
936 self.iter = False
935 self.iter = False
937 self.buf = collector.getvalue()
936 self.buf = ''.join(collector)
938 if len(self.buf) == l:
937 if len(self.buf) == l:
939 s, self.buf = str(self.buf), ''
938 s, self.buf = str(self.buf), ''
940 else:
939 else:
General Comments 0
You need to be logged in to leave comments. Login now