Skip to content

Commit

Permalink
fix some details
Browse files Browse the repository at this point in the history
  • Loading branch information
thefab committed Feb 25, 2015
1 parent 77d333e commit e98b406
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tornadis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ def _append(self, data, right):
else:
self._deque.extendleft(data._deque)
self._total_length += data._total_length
self._has_view = self._has_view and data._has_view
else:
length = len(data)
if length == 0:
return
if isinstance(data, memoryview):
# data is a memory viewobject
# nothing spacial but now the buffer has views
self._has_view = True
length = len(data)
if length == 0:
return
self._total_length += length
if right:
self._deque.append(data)
Expand Down Expand Up @@ -146,18 +147,19 @@ def get_pointer_or_memoryview(self, data, data_length):
def get_chunk(self, chunk_max_size):
"""Gets a chunk of the given max size.
Optimized to avoid too much string copies.
Args:
chunk_max_size (int): max size of the returned chunk
chunk_max_size (int): max size of the returned chunk.
Returns:
FIXME
string (bytes) with a size <= chunk_max_size.
"""
if self._total_length < chunk_max_size:
# fastpath (the whole queue fit in a single chunk)
res = self._tobytes()
self._reset()
return res
chunk_write_buffer = WriteBuffer()
first_iteration = True
while True:
try:
Expand Down

0 comments on commit e98b406

Please sign in to comment.