]> git.evergreen-ils.org Git - OpenSRF.git/commit
This update boosts the performance of the jsonFormatString function.
authorscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 5 Jan 2009 17:50:15 +0000 (17:50 +0000)
committerscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 5 Jan 2009 17:50:15 +0000 (17:50 +0000)
commit49c7c159456fd6ed23278ea0fb0461aac4b38941
tree1c7e0df5ca85a5d8c0449ebd50f6d1b841f7ca7c
parentaf61b0530efd864ec78367265a97baa1a9439752
This update boosts the performance of the jsonFormatString function.

1. Replaced the old _tabs function, which required the construction and
destruction of a growing_buffer, with a new append_indentation function,
which adds white space to an existing growing_buffer.  This change
eliminates a passel of mallocs and frees.

2. Removed the call to strlen() from the loop condition.

3. Replaced calls to buffer_fadd(), a fairly slow function, with calls
to OSRF_BUFFER_ADD_CHAR() and append_indentation().  Also: replaced a
call to buffer_add_char with the corresponding macro.

4. Eliminated a harmless but wasteful bug that sometimes added
indentation to the end of a line.

In my benchmarking, using a moderately complex JSON string 201
characters long, the new version was seven times as fast as the old.

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1571 9efc2488-bf62-4759-914b-345cdb29e865
src/libopensrf/osrf_json_tools.c