]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Use strspn() to accelerate whitespace bypass in the JSON parser.
authordrh <>
Tue, 5 Dec 2023 12:52:13 +0000 (12:52 +0000)
committerdrh <>
Tue, 5 Dec 2023 12:52:13 +0000 (12:52 +0000)
FossilOrigin-Name: 843197df08352bdff4b87be91d160e574572aded0d0c66142fd960000c0b4701

manifest
manifest.uuid
src/json.c

index 483ed625115b3d0ab068fcb7c0b851fdba3ecd79..e5224d07aadae7a3989c02b6bccf41d663aae9c5 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Small\sperformance\sgain\sby\sunwinding\sthe\sstring\sliteral\sdelimiter\ssearch\nloop\sin\sthe\sJSON\sparser\sby\sone\smore\slevel.
-D 2023-12-05T12:22:05.245
+C Use\sstrspn()\sto\saccelerate\swhitespace\sbypass\sin\sthe\sJSON\sparser.
+D 2023-12-05T12:52:13.143
 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 53d9e4ea2e1b33ea0f0dc629d08605748056333c57ff03ea8b6cfdcc585a4dc0
+F src/json.c 752aabf2c961d5d79143ae4a2b41d1bf60d4ec15110b0b75c5c3de5fe62d4dd1
 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 905301075a7fc1010ee7e754867b1b698c9b8576d50e98125def32a5dfb7ee9d
-R ec589ba3fd8295a6ff09aeae12dc3bd7
+P 4c587feac153e8ebe526559ec3d254f545f81e8d1ed3126f91a5ff25ec4aa72e
+R 7ec679fd53493789f3af3780d93617a7
 U drh
-Z 7a001bd7445e746508caf3ed9f69266e
+Z be9b20ef175c9b8d4ac4f39def382e58
 # Remove this line to create a well-formed Fossil manifest.
index 5ad309bbc2cf8c147860ec36837ac8bb0e36d610..3eb7382c63ea9a34dc70d596d9bcf47d545c3c2d 100644 (file)
@@ -1 +1 @@
-4c587feac153e8ebe526559ec3d254f545f81e8d1ed3126f91a5ff25ec4aa72e
\ No newline at end of file
+843197df08352bdff4b87be91d160e574572aded0d0c66142fd960000c0b4701
\ No newline at end of file
index ff488de4ecf98dbcd4d2f356598edd77abe628ce..2fc6c8b74f93106f0a9a34be4d9b4625851ce622 100644 (file)
@@ -168,6 +168,12 @@ static const char jsonIsSpace[] = {
 };
 #define jsonIsspace(x) (jsonIsSpace[(unsigned char)x])
 
+/*
+** The set of all space characters recognized by jsonIsspace().
+** Useful as an argument to strspn().
+*/
+static const char jsonSpaces[] = "\011\012\015\040";
+
 /*
 ** Characters that are special to JSON.  Control characters,
 ** '"' and '\\'.
@@ -1296,6 +1302,7 @@ json_parse_restart:
         j++;
       }else{
         if( jsonIsspace(z[j]) ){
+          /* strspn() is not helpful here */
           do{ j++; }while( jsonIsspace(z[j]) );
           if( z[j]==':' ){
             j++;
@@ -1322,7 +1329,7 @@ json_parse_restart:
         break;
       }else{
         if( jsonIsspace(z[j]) ){
-          do{ j++; }while( jsonIsspace(z[j]) );
+          j += 1 + strspn(&z[j+1], jsonSpaces);
           if( z[j]==',' ){
             continue;
           }else if( z[j]=='}' ){
@@ -1374,7 +1381,7 @@ json_parse_restart:
         break;
       }else{
         if( jsonIsspace(z[j]) ){
-          do{ j++; }while( jsonIsspace(z[j]) );
+          j += 1 + strspn(&z[j+1], jsonSpaces);
           if( z[j]==',' ){
             continue;
           }else if( z[j]==']' ){
@@ -1635,9 +1642,7 @@ json_parse_restart:
   case 0x0a:
   case 0x0d:
   case 0x20: {
-    do{
-      i++;
-    }while( jsonIsspace(z[i]) );
+    i += 1 + strspn(&z[i+1], jsonSpaces);
     goto json_parse_restart;
   }
   case 0x0b: