refactor(shada): rework msgpack decoding without msgpack-c

This also makes shada reading slightly faster due to avoiding
some copying and allocation.

Use keysets to drive decoding of msgpack maps for shada entries.
This commit is contained in:
bfredl
2024-07-02 13:45:50 +02:00
parent 0c2860d9e5
commit f926cc32c9
42 changed files with 1025 additions and 1165 deletions

View File

@@ -309,6 +309,22 @@ ptrdiff_t file_read(FileDescriptor *const fp, char *const ret_buf, const size_t
return (ptrdiff_t)(size - read_remaining);
}
/// try to read already buffered data in place
///
/// @return NULL if enough data is not available
/// valid pointer to chunk of "size". pointer becomes invalid in the next "file_read" call!
char *file_try_read_buffered(FileDescriptor *const fp, const size_t size)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
if ((size_t)(fp->write_pos - fp->read_pos) >= size) {
char *ret = fp->read_pos;
fp->read_pos += size;
fp->bytes_read += size;
return ret;
}
return NULL;
}
/// Write to a file
///
/// @param[in] fd File descriptor to write to.