MCPcopy Create free account
hub / github.com/EasyIME/PIME / _consume

Method _consume

python/python3/tornado/iostream.py:996–1015  ·  view source on GitHub ↗
(self, loc: int)

Source from the content-addressed store, hash-verified

994 future_set_result_unless_cancelled(future, None)
995
996 def _consume(self, loc: int) -> bytes:
997 # Consume loc bytes from the read buffer and return them
998 if loc == 0:
999 return b""
1000 assert loc <= self._read_buffer_size
1001 # Slice the bytearray buffer into bytes, without intermediate copying
1002 b = (
1003 memoryview(self._read_buffer)[
1004 self._read_buffer_pos : self._read_buffer_pos + loc
1005 ]
1006 ).tobytes()
1007 self._read_buffer_pos += loc
1008 self._read_buffer_size -= loc
1009 # Amortized O(1) shrink
1010 # (this heuristic is implemented natively in Python 3.4+
1011 # but is replicated here for Python 2)
1012 if self._read_buffer_pos > self._read_buffer_size:
1013 del self._read_buffer[: self._read_buffer_pos]
1014 self._read_buffer_pos = 0
1015 return b
1016
1017 def _check_closed(self) -> None:
1018 if self.closed():

Callers 1

_finish_readMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected