mirror of
https://github.com/neovim/neovim.git
synced 2025-09-10 05:18:16 +00:00
refactor(api): use a unpacker based on libmpack instead of msgpack-c
Currently this is more or less a straight off reimplementation, but this allow further optimizations down the line, especially for avoiding memory allocations of rpc objects. Current score for "make functionaltest; make oldtest" on a -DEXITFREE build: is 117 055 352 xfree(ptr != NULL) calls (that's NUMBERWANG!).
This commit is contained in:
@@ -154,6 +154,23 @@ void rbuffer_consumed(RBuffer *buf, size_t count)
|
||||
}
|
||||
}
|
||||
|
||||
/// Use instead of rbuffer_consumed to use rbuffer in a linear, non-cyclic fashion.
|
||||
///
|
||||
/// This is generally usefull if we can guarantee to parse all input
|
||||
/// except some small incomplete token, like when parsing msgpack.
|
||||
void rbuffer_consumed_compact(RBuffer *buf, size_t count)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
assert(buf->read_ptr <= buf->write_ptr);
|
||||
rbuffer_consumed(buf, count);
|
||||
if (buf->read_ptr > buf->start_ptr) {
|
||||
assert((size_t)(buf->read_ptr - buf->write_ptr) == buf->size);
|
||||
memmove(buf->start_ptr, buf->read_ptr, buf->size);
|
||||
buf->read_ptr = buf->start_ptr;
|
||||
buf->write_ptr = buf->read_ptr + buf->size;
|
||||
}
|
||||
}
|
||||
|
||||
// Higher level functions for copying from/to RBuffer instances and data
|
||||
// pointers
|
||||
size_t rbuffer_write(RBuffer *buf, const char *src, size_t src_size)
|
||||
|
Reference in New Issue
Block a user