numam-spdk/lib/json
Daniel Verkamp 38c09e5eed json/parse: rewrite and simplify number parsing
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>
2017-01-13 13:18:50 -07:00
..
json_internal.h json/write: add an output buffer 2017-01-13 13:18:50 -07:00
json_parse.c json/parse: rewrite and simplify number parsing 2017-01-13 13:18:50 -07:00
json_util.c json: add JSON parser and encoder libraries 2016-05-09 13:30:02 -07:00
json_write.c json/write: add an output buffer 2017-01-13 13:18:50 -07:00
Makefile build: include spdk.common.mk in lib Makefiles 2016-07-18 16:17:40 -07:00