From 2ff73a5f3e6eef0c1cc5423f7d7b41db1f435378 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 4 Dec 2023 01:14:23 +0000 Subject: [PATCH] Better pre-scan size estimations for objects in the JSON parser resulting in fewer reallocations and memmove operations. FossilOrigin-Name: 526b27f90897f5e35dfff7257daf6c4ce4798d649b09b8aecfb02df0449e3c51 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a102fa7874..f5a4a19dce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\soff\son\sthe\suse\sof\sstrlen()\sfor\ssituations\swhere\ssqlite3_value_bytes()\nwill\swork\sas\swell,\sfor\sperformance. -D 2023-12-04T00:31:58.791 +C Better\spre-scan\ssize\sestimations\sfor\sobjects\sin\sthe\sJSON\sparser\sresulting\nin\sfewer\sreallocations\sand\smemmove\soperations. +D 2023-12-04T01:14:23.183 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -688,7 +688,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 4cf9581f5d58cac15136c40dc359910eda0bac0508173ac1e2c2d988c7b9f310 +F src/json.c fe5c8d7494ed56126553dbcb5c970dcbbadddfd56871e08b905b8d7fb9903417 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9 @@ -2145,8 +2145,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2eaa738e6b5c1b67b3e57c868d9c3a30eea38a0b3b8b02482f06d57a45b10921 -R 38b2727d0c66c3371d75d1e0b8d86ea5 +P 79fb54fbb8b9c30f47cdbd437d24a21542716241e822749e5e28c9fbc449bfa8 +R dfc9eac13900dae64608fce7f4f645e4 U drh -Z 2acd0d3ecb5d5f83c97261113a2445b2 +Z 0536405657c5f5cc41f38cd4401ae262 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 965abfdee1..deb93d36ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -79fb54fbb8b9c30f47cdbd437d24a21542716241e822749e5e28c9fbc449bfa8 \ No newline at end of file +526b27f90897f5e35dfff7257daf6c4ce4798d649b09b8aecfb02df0449e3c51 \ No newline at end of file diff --git a/src/json.c b/src/json.c index f5eef834d0..598b290510 100644 --- a/src/json.c +++ b/src/json.c @@ -1268,7 +1268,7 @@ json_parse_restart: case '{': { /* Parse object */ iThis = pParse->nBlob; - jsonBlobAppendNode(pParse, JSONB_OBJECT, (pParse->nJson-i)*2, 0); + jsonBlobAppendNode(pParse, JSONB_OBJECT, pParse->nJson-i, 0); if( ++pParse->iDepth > JSON_MAX_DEPTH ){ pParse->iErr = i; return -1;