38c09e5eed
Convert the number parsing function into a linear sequence with a goto label for each state, rather than a single loop with a state variable. This makes the code easier to read and also improves speed (better branch prediction and smaller inner loops for the common case). On my test system, jsoncat citylots.json > /dev/null improves from ~1.7s to ~1.2s. This changes behavior of some number parsing test cases: inputs matching the number grammar as defined by JSON will be returned even if there is trailing garbage, consistent with the rest of the parser. For example, the input 01 will be parsed as a valid number 0 followed by trailing 1. This only makes any difference when the full input is a single number value, since if the value was nested in an object or array, the trailing garbage will not match the expected syntax and the whole parse will fail with SPDK_JSON_PARSE_INVALID (e.g. [00 will parse the first 0 as a number and then fail on the second 0, since only a comma or right square bracket would be accepted). Change-Id: Ifabfaed611219b3e0a06c8677190a28b87e8a13b Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> |
||
---|---|---|
.. | ||
json_internal.h | ||
json_parse.c | ||
json_util.c | ||
json_write.c | ||
Makefile |