binbuf autogrow #29

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
3 participants
@lodevil
Contributor

lodevil commented Aug 18, 2014

No description provided.

@lxyu lxyu closed this in 55d04c5 Aug 19, 2014

@@ -27,6 +27,24 @@ cdef class Buffer(object):
self.cur = 0
self.data_size = 0
+ cdef int grow(self, int min_size):
+ if min_size <= self.buf_size:
+ return

This comment has been minimized.

@lxyu

lxyu Aug 19, 2014

Contributor

fyi, merged as return 0 in 55d04c5

@lxyu

lxyu Aug 19, 2014

Contributor

fyi, merged as return 0 in 55d04c5

new_data = self.trans._read(cap)
# buf + buf_size >= buf + cur + data_size + new_data_len -->
# buf_size - data_size >= cur + new_data_len -->
# cap - cur >= new_data_len
- if cap - self.rbuf.cur < len(new_data) or cap < 256:
+ if cap < len(new_data):

This comment has been minimized.

@lxyu

lxyu Aug 19, 2014

Contributor

这行和上面那行是不能改的,tests 出错了。我merge的时候改回去了。

@lxyu

lxyu Aug 19, 2014

Contributor

这行和上面那行是不能改的,tests 出错了。我merge的时候改回去了。

cdef int cap
cdef bytes new_data
if self.rbuf.data_size == 0:
self.rbuf.cur = 0
if self.rbuf.data_size < size:
- cap = self.rbuf.buf_size - self.rbuf.data_size
+ cap = self.rbuf.buf_size - self.rbuf.cur - self.rbuf.data_size

This comment has been minimized.

@maralla

maralla Aug 19, 2014

Contributor

这个地方算可用空间的时候为何要减去self.rbuf.cur
self.rbuf.data_size是存进去的可用数据量, self.rbuf.buf_size是当前buffer的大小,两者之差才是可用空间的大小啊。@lodevil

@maralla

maralla Aug 19, 2014

Contributor

这个地方算可用空间的时候为何要减去self.rbuf.cur
self.rbuf.data_size是存进去的可用数据量, self.rbuf.buf_size是当前buffer的大小,两者之差才是可用空间的大小啊。@lodevil

This comment has been minimized.

@lodevil

lodevil Aug 19, 2014

Contributor

rbuf.cur 是数据的起始地址
rbuf.data_size是存储的数据大小,是从rbuf.cur开始的
cap是rbuf可连续使用的空间大小,即从rbuf.cur + rbuf.data_size到rbuf.buf_size那一段的空间
所以cap = rbuf.buf_size - rbuf.cur - rbuf.data_size

@lodevil

lodevil Aug 19, 2014

Contributor

rbuf.cur 是数据的起始地址
rbuf.data_size是存储的数据大小,是从rbuf.cur开始的
cap是rbuf可连续使用的空间大小,即从rbuf.cur + rbuf.data_size到rbuf.buf_size那一段的空间
所以cap = rbuf.buf_size - rbuf.cur - rbuf.data_size

@pyup-bot pyup-bot referenced this pull request in scieloorg/opac_proc Aug 18, 2016

Closed

Initial Update #10

@pyup-bot pyup-bot referenced this pull request in scieloorg/scielo-manager Aug 26, 2016

Closed

Pin thriftpy to latest version 0.3.9 #1314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment