]> git.ipfire.org Git - thirdparty/json-c.git/commit
more efficient handling for smalls strings inside json_object 196/head
authorRainer Gerhards <rgerhards@adiscon.com>
Wed, 23 Sep 2015 13:56:48 +0000 (15:56 +0200)
committerRainer Gerhards <rgerhards@adiscon.com>
Wed, 23 Sep 2015 13:56:48 +0000 (15:56 +0200)
commitc4f8cc34df91715d008166e4748c5f32ee894698
tree5ea6896e71d5786d3e7199dc6ee8abddda8f9b87
parent1ae4b50bdedfde89f179c7538ecf886d175a59b0
more efficient handling for smalls strings inside json_object

smalls strings inside json_objects had a high overhead because dynamic
memory allocation was needed for each of them. This also meant that the
pointer needed to be updated. This is now changed so that small strings
can directly be stored inside the json_object. Note that on the regular
64 bit machines a pointer takes 8 bytes. So even without increasing
memory, we could store string up to 7 bytes directly inside the object.
The max size is configurable. I have selected up to 31 bytes (which
means a buffer of 32 including the NUL byte). This brings a 24-bytes
memory overhead, but I consider that still useful because the memory
allocator usually also has quite some overhead (16 bytes) for
dyn alloced memory blocks. In any case, the max buffer size can be
tweaked via #define.
json_object.c
json_object_private.h