Good...Good...
This commit is contained in:
parent
e73b038c3e
commit
0e5bcd5f77
1 changed files with 2 additions and 5 deletions
|
@ -20,7 +20,6 @@ class LineBuffer():
|
||||||
def _shift(self):
|
def _shift(self):
|
||||||
count = self.offset_i - self.offset_o
|
count = self.offset_i - self.offset_o
|
||||||
|
|
||||||
|
|
||||||
self.buf[0:count] = self.buf[self.offset_o:self.offset_i]
|
self.buf[0:count] = self.buf[self.offset_o:self.offset_i]
|
||||||
|
|
||||||
self.offset_i = count
|
self.offset_i = count
|
||||||
|
@ -41,7 +40,6 @@ class LineBuffer():
|
||||||
|
|
||||||
readlen = len(data)
|
readlen = len(data)
|
||||||
|
|
||||||
|
|
||||||
self.buf[self.offset_i:self.size] = data
|
self.buf[self.offset_i:self.size] = data
|
||||||
|
|
||||||
self.offset_i += readlen
|
self.offset_i += readlen
|
||||||
|
@ -59,16 +57,15 @@ class LineBuffer():
|
||||||
def readline(self, sock: socket.socket) -> str:
|
def readline(self, sock: socket.socket) -> str:
|
||||||
if self.done:
|
if self.done:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
index = self.buf.find(b'\n', self.offset_o, self.offset_i)
|
index = self.buf.find(b'\n', self.offset_o, self.offset_i)
|
||||||
|
|
||||||
|
|
||||||
if index < 0:
|
if index < 0:
|
||||||
if self._is_full():
|
if self._is_full():
|
||||||
if self.offset_o == 0:
|
if self.offset_o == 0:
|
||||||
raise BufferOverflow()
|
raise BufferOverflow()
|
||||||
|
|
||||||
self._shift()
|
self._shift()
|
||||||
elif self.eof:
|
elif self.eof:
|
||||||
self.done = True
|
self.done = True
|
||||||
|
|
Loading…
Add table
Reference in a new issue