mirror of
https://github.com/gvx/bitser.git
synced 2025-01-16 03:24:19 +00:00
Reduce copying of buffer when reserving
This commit is contained in:
parent
0742c8d878
commit
493bc00af8
@ -78,8 +78,10 @@ local function Buffer_newDataReader(data, size)
|
||||
end
|
||||
|
||||
local function Buffer_reserve(additional_size)
|
||||
while buf_pos + additional_size > buf_size do
|
||||
buf_size = buf_size * 2
|
||||
if buf_pos + additional_size > buf_size do
|
||||
repeat
|
||||
buf_size = buf_size * 2
|
||||
until buf_pos + additional_size <= buf_size
|
||||
local oldbuf = buf
|
||||
buf = ffi.new("uint8_t[?]", buf_size)
|
||||
buf_is_writable = true
|
||||
|
Loading…
Reference in New Issue
Block a user