mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Rework cJSON_Utils object compare functions to use an O(N) algorithm on sorted lists.
It's a bit of a shame to use the sorts, because cJSON is otherwise incredibly stable (json->cJSON->json is unmodified modulo formatting), but it means we get usable performance, rather than O(N^2) which will make CPUs cry. git-svn-id: svn://svn.code.sf.net/p/cjson/code@71 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
@@ -101,9 +101,9 @@ int main()
|
||||
{
|
||||
buf[0]=random[i];cJSON_AddItemToObject(sortme,buf,cJSON_CreateNumber(1));
|
||||
}
|
||||
before=cJSON_Print(sortme);
|
||||
before=cJSON_PrintUnformatted(sortme);
|
||||
cJSONUtils_SortObject(sortme);
|
||||
after=cJSON_Print(sortme);
|
||||
after=cJSON_PrintUnformatted(sortme);
|
||||
printf("Before: [%s]\nAfter: [%s]\n\n",before,after);
|
||||
free(before);free(after);cJSON_Delete(sortme);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user