On my JSON.dump benchmark it shows up as 6% of runtime, compared to 40% for convert_UTF8_to_JSON.
Since the vast majority of the time this function is called we still have some buffer capacity, we might as well check that first and skip the expensive loop etc.
With this change my profiler now report this function as 0.7%, so almost 10x better.
[flori/json] Optimize
fbuffer_inc_capaOn my
JSON.dumpbenchmark it shows up as 6% of runtime, comparedto 40% for
convert_UTF8_to_JSON.Since the vast majority of the time this function is called we
still have some buffer capacity, we might as well check that
first and skip the expensive loop etc.
With this change my profiler now report this function as 0.7%,
so almost 10x better.
https://github.com/flori/json/commit/a7206bf2db