]> git.evergreen-ils.org Git - OpenSRF.git/commit
Performance tweak to message handling.
authorscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 5 Oct 2009 16:29:57 +0000 (16:29 +0000)
committerscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 5 Oct 2009 16:29:57 +0000 (16:29 +0000)
commitb193d7d98131b5b9a31481a2cfb724f347cb269c
tree7d86025699ffb8643ac9fa125af16714368343c9
parentb264a161738c61cd3f3197f676d7c7780e4ae8e8
Performance tweak to message handling.

In five locations in osrf_message.c, we were turning a jsonObject into
a JSON string, only to parse it again back into a jsonObject:

-- osrf_message_add_object_param()
-- osrfMessageToJSON() (two occurrences)
-- osrf_message_deserialize() (two occurrences)

That's silly.

This new version copies the original jsonObject directly, with no round
trip through a JSON string.  We use jsonObjectDecodeClass() to do the
copy, in order to make sure that all class hints are decoded into
classnames.

(Until recently, jsonObjectDecodeClass() would remove classnames that were
already present.  That's presumably the reason for the curious and
inefficient two-step procedure that we were using up till now.)

Also: In two locations (in osrf_message_add_object_param() and
osrf_message_add_param())  We used jsonParseString() to parse a
hard-coded "[]".  I replaced those calls with equivalent (and faster)
calls to jsonNewObjectType( JSON_ARRAY );

Also: in osrf_message_set_result_content() I eliminated a pointless test
for nullity of the json_string variable.  An earlier test already
guarantees that json_string is not NULL.

M    src/libopensrf/osrf_message.c

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