]> git.evergreen-ils.org Git - OpenSRF.git/commit
Enhance the performance of the recursive descent JSON parser,
authorscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Sun, 4 Oct 2009 15:13:36 +0000 (15:13 +0000)
committerscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Sun, 4 Oct 2009 15:13:36 +0000 (15:13 +0000)
commitbc078a5e8fd679c63ad2dc790b2f397d2c47f050
treebd4c5b47204669ce71f7eb796b1fb51a0f6f8217
parentf915dc58a9458a42dceadd2ece94f63e75ef893a
Enhance the performance of the recursive descent JSON parser,
mainly the jsonParse() function.

1. The old version would create a jsonObject and then copy it, with
possible modifications, via a call to jsonObjectDecodeClass(), in
order to decode class hints into the classname member.  Finally, it
would throw away the original jsonObject.

The copying operation is expensive, and the new version eliminates
it.  When decoding is desired (which is nearly always), execution
passes through a parallel version of the get_hash() function, which
does the decoding on the fly.

In my benchmarking, the new version reduces the parsing time by
around 35 - 45 percent.  It is now at least twice as fast as the
older jsonParseString() function, which uses a finite state
machine instead of recursive descent.

2. In get_number(): instead of allocating and destroying a
temporary growing_buffer, use the one available in the
Parser structure.

3. In osrf_json.h: Applied some pedantic corrections to the
doxygen comments for the old parser.

--------

In all cases tested, the new version produces results identical
to those of the old version.  The results are also identical to
those of the older parser, apart from error detection.

M    include/opensrf/osrf_json.h
M    src/libopensrf/osrf_parse_json.c

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1804 9efc2488-bf62-4759-914b-345cdb29e865
include/opensrf/osrf_json.h
src/libopensrf/osrf_parse_json.c