bitsery
bitsery copied to clipboard
pass cursor and needed byte space to BufferAdapterTraits::increaseBufferSize
two insights seen when resizing buffers...
-
when inserting an object much larger than the current buffer size, the current implementation will loop many times until the buffer grows large enough, burning several unnecessary allocations and memcpy-s in the worst case. so inform the implementation how many bytes we need.
-
when implementing an alloc + memcpy, since the buffer's length isn't updated until after the serialization, we're forced to copy the entire capacity. though this capacity is insufficient to accommodate the new addition, we still might be copying excess bytes. very mildly cleaner this way. wouldn't warrant a PR without 1) though.
the 1st test failed because the couldn't pull a resource from the network, and the other 2 because the parameters are currently unused in the StdContainer implementation.
Hello, Actually, this is very good idea, especially the part of enforcing at least bytes allocation. I want to play with this idea, as it might bring some performance improvements basically for free!
This is implemented in v5.2.3.