1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Fix harmless compiler warnings and enhance performance the parser.

FossilOrigin-Name: 285633da6d188547e52f07779e209c9e5f3dc33ce0668e14858f3337889ef4b8
This commit is contained in:
drh
2023-12-02 01:06:33 +00:00
parent 3af20cf3a0
commit 5ec9c916ad
3 changed files with 36 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
C Performance\soptimization\sin\sthe\sJSON\sparser.
D 2023-12-01T22:01:26.348
C Fix\sharmless\scompiler\swarnings\sand\senhance\sperformance\sthe\sparser.
D 2023-12-02T01:06:33.225
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 d524f2f13338f84327641edd5b422252d7c93a4f7fc57f083a0d41c767561554
F src/json.c 58c3ded3bdc94125235a805214016147ecd63f8173cff19a7084c9fb0ea0ff9c
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 443a3f3a8e64d81cad8300a30e2cc57c4e39f69b5669ac8b550c590ae9f1134a
R a25493165248fa490fe7a3cb972ea0d2
P 68d191f40e708962ec88e0c245b4496bc4a671300484b1cc0f3fc7e6d199a6e6
R 398de78fe5dea0e1b0bc6535ce40a9fc
U drh
Z 51cb7fe7cb06e4de05d17231c2159ec6
Z c1eeb98e2ab1260bdea70d2e8aff46bd
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
68d191f40e708962ec88e0c245b4496bc4a671300484b1cc0f3fc7e6d199a6e6
285633da6d188547e52f07779e209c9e5f3dc33ce0668e14858f3337889ef4b8

View File

@@ -1075,6 +1075,17 @@ static int jsonBlobAppendNBytes(JsonParse *pParse, const u8 *aData, u32 N){
return 0;
}
static void jsonBlobAppendNodeType(JsonParse*,u8,u32);
static SQLITE_NOINLINE void jsonBlobExpandAndAppendNodeType(
JsonParse *pParse,
u8 eType,
u32 szPayload
){
if( jsonBlobExpand(pParse, pParse->nBlob+szPayload+9) ) return;
jsonBlobAppendNodeType(pParse, eType, szPayload);
}
/* Append an node type byte together with the payload size.
*/
static void jsonBlobAppendNodeType(
@@ -1082,25 +1093,31 @@ static void jsonBlobAppendNodeType(
u8 eType,
u32 szPayload
){
u8 a[5];
u8 *a;
if( pParse->nBlob+szPayload+9 > pParse->nBlobAlloc ){
jsonBlobExpandAndAppendNodeType(pParse,eType,szPayload);
return;
}
a = &pParse->aBlob[pParse->nBlob];
if( szPayload<=11 ){
jsonBlobAppendOneByte(pParse, eType | (szPayload<<4));
a[0] = eType | (szPayload<<4);
pParse->nBlob += 1;
}else if( szPayload<=0xff ){
a[0] = eType | 0xc0;
a[1] = szPayload & 0xff;
jsonBlobAppendNBytes(pParse, a, 2);
pParse->nBlob += 2;
}else if( szPayload<=0xffff ){
a[0] = eType | 0xd0;
a[1] = (szPayload >> 8) & 0xff;
a[2] = szPayload & 0xff;
jsonBlobAppendNBytes(pParse, a, 3);
pParse->nBlob += 3;
}else{
a[0] = eType | 0xe0;
a[1] = (szPayload >> 24) & 0xff;
a[2] = (szPayload >> 16) & 0xff;
a[3] = (szPayload >> 8) & 0xff;
a[4] = szPayload & 0xff;
jsonBlobAppendNBytes(pParse, a, 5);
pParse->nBlob += 5;
}
}
@@ -2169,12 +2186,9 @@ static u32 jsonLookupBlobStep(
u32 nIns; /* Total bytes to insert (label+value) */
JsonParse v; /* BLOB encoding of the value to be inserted */
JsonParse ix; /* Header of the label to be inserted */
u8 aLabel[16]; /* Buffer space for ix */
testcase( pParse->eEdit==JEDIT_INS );
testcase( pParse->eEdit==JEDIT_SET );
memset(&ix, 0, sizeof(ix));
ix.aBlob = aLabel;
ix.nBlobAlloc = sizeof(aLabel);
jsonBlobAppendNodeType(&ix,JSONB_TEXTRAW, nKey);
memset(&v, 0, sizeof(v));
if( zPath[i]==0 ){
@@ -2190,9 +2204,11 @@ static u32 jsonLookupBlobStep(
if( JSON_BLOB_ISERROR(rc) || v.oom ){
pParse->oom |= v.oom;
jsonParseReset(&v);
jsonParseReset(&ix);
return rc;
}
}
pParse->oom |= ix.oom;
if( jsonBlobMakeEditable(pParse, ix.nBlob+nKey+v.nBlob) ){
nIns = ix.nBlob + nKey + v.nBlob;
jsonBlobEdit(pParse, j, 0, 0, nIns);
@@ -2204,6 +2220,7 @@ static u32 jsonLookupBlobStep(
if( pParse->delta ) jsonAfterEditSizeAdjust(pParse, iRoot);
}
jsonParseReset(&v);
jsonParseReset(&ix);
return j;
}
}else if( zPath[0]=='[' ){
@@ -3323,11 +3340,11 @@ static int jsonMergePatchBlob(
u32 iTEndBE; /* Original first byte past end of target, before edit */
u32 iTEnd; /* Current first byte past end of target */
u8 eTLabel; /* Node type of the target label */
u32 iTLabel; /* Index of the label */
u32 nTLabel; /* Header size in bytes for the target label */
u32 iTLabel = 0; /* Index of the label */
u32 nTLabel = 0; /* Header size in bytes for the target label */
u32 szTLabel; /* Size of the target label payload */
u32 iTValue; /* Index of the target value */
u32 nTValue; /* Header size of the target value */
u32 iTValue = 0; /* Index of the target value */
u32 nTValue = 0; /* Header size of the target value */
u32 szTValue; /* Payload size for the target value */
u32 iPCursor; /* Cursor position while scanning the patch */