mirror of
https://github.com/rafagafe/tiny-json.git
synced 2025-03-12 19:25:30 +00:00
Merge pull request #1 from vanjoe/master
Speed up adding of large arrays.
This commit is contained in:
commit
2e98dd7e63
11
tiny-json.c
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,10 @@ typedef struct json_s {
|
|||||||
char const* name;
|
char const* name;
|
||||||
union {
|
union {
|
||||||
char const* value;
|
char const* value;
|
||||||
struct json_s* child;
|
struct {
|
||||||
|
struct json_s* child;
|
||||||
|
struct json_s* last_child;
|
||||||
|
};
|
||||||
} u;
|
} u;
|
||||||
jsonType_t type;
|
jsonType_t type;
|
||||||
} json_t;
|
} json_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user