OK, one more hack: speed up the case of readline() in unbuffered mode.
This is important IMO because httplib reads the headers this way.
This commit is contained in:
parent
fb3deec2fc
commit
48b7969af8
|
@ -307,6 +307,17 @@ class _fileobject(object):
|
||||||
data = self._rbuf
|
data = self._rbuf
|
||||||
if size < 0:
|
if size < 0:
|
||||||
# Read until \n or EOF, whichever comes first
|
# Read until \n or EOF, whichever comes first
|
||||||
|
if self._rbufsize <= 1:
|
||||||
|
# Speed up unbuffered case
|
||||||
|
assert data == ""
|
||||||
|
buffers = []
|
||||||
|
recv = self._sock.recv
|
||||||
|
while data != "\n":
|
||||||
|
data = recv(1)
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
buffers.append(data)
|
||||||
|
return "".join(buffers)
|
||||||
nl = data.find('\n')
|
nl = data.find('\n')
|
||||||
if nl >= 0:
|
if nl >= 0:
|
||||||
nl += 1
|
nl += 1
|
||||||
|
|
Loading…
Reference in New Issue