speed up large arrays

pull/1/head
Joel Vandergriendt 7 years ago
parent 210935cb44
commit 2f6c919986
  1. 11
      tiny-json.c

@ -300,11 +300,12 @@ static char* numValue( char* ptr, json_t* property ) {
* @param property The handler of the property to be added. */ * @param property The handler of the property to be added. */
static void add( json_t* obj, json_t* property ) { static void add( json_t* obj, json_t* property ) {
property->sibling = 0; property->sibling = 0;
if ( !obj->u.child ) obj->u.child = property; if ( !obj->u.child ){
else { obj->u.child = property;
json_t* iter; obj->u.last_child = property;
for( iter = obj->u.child; iter->sibling; iter = iter->sibling ); } else {
iter->sibling = property; obj->u.last_child->sibling = property;
obj->u.last_child = property;
} }
} }

Loading…
Cancel
Save