##// END OF EJS Templates
bufferedinputpipe: remove N^2 computation of buffer length (issue4735)...
Pierre-Yves David -
r25672:050dc6ea default
parent child Browse files
Show More
@@ -254,6 +254,7 b' class bufferedinputpipe(object):'
254 254 self._input = input
255 255 self._buffer = []
256 256 self._eof = False
257 self._lenbuf = 0
257 258
258 259 @property
259 260 def hasbuffer(self):
@@ -283,6 +284,7 b' class bufferedinputpipe(object):'
283 284 # this should not happen because both read and readline end with a
284 285 # _frombuffer call that collapse it.
285 286 self._buffer = [''.join(self._buffer)]
287 self._lenbuf = len(self._buffer[0])
286 288 lfi = -1
287 289 if self._buffer:
288 290 lfi = self._buffer[-1].find('\n')
@@ -298,11 +300,6 b' class bufferedinputpipe(object):'
298 300 size += self._lenbuf - len(self._buffer[-1])
299 301 return self._frombuffer(size)
300 302
301 @property
302 def _lenbuf(self):
303 """return the current lengh of buffered data"""
304 return sum(len(d) for d in self._buffer)
305
306 303 def _frombuffer(self, size):
307 304 """return at most 'size' data from the buffer
308 305
@@ -317,8 +314,10 b' class bufferedinputpipe(object):'
317 314 buf = buf[len(data):]
318 315 if buf:
319 316 self._buffer = [buf]
317 self._lenbuf = len(buf)
320 318 else:
321 319 self._buffer = []
320 self._lenbuf = 0
322 321 return data
323 322
324 323 def _fillbuffer(self):
@@ -327,6 +326,7 b' class bufferedinputpipe(object):'
327 326 if not data:
328 327 self._eof = True
329 328 else:
329 self._lenbuf += len(data)
330 330 self._buffer.append(data)
331 331
332 332 def popen2(cmd, env=None, newlines=False):
General Comments 0
You need to be logged in to leave comments. Login now