diff options
author | drh <> | 2023-07-19 17:24:36 +0000 |
---|---|---|
committer | drh <> | 2023-07-19 17:24:36 +0000 |
commit | 50834d8b74a88736dcf50e334197bcebe54b55ec (patch) | |
tree | adcd8be300432acd070d66148dd8d16681c9046f /src/json.c | |
parent | 8376ae7295a241fdac53ef67e8be261b069d39ba (diff) | |
download | sqlite-50834d8b74a88736dcf50e334197bcebe54b55ec.tar.gz sqlite-50834d8b74a88736dcf50e334197bcebe54b55ec.zip |
Further improvement to JSON parser performance.
FossilOrigin-Name: 144c8ccf6e5bb2527dd98742f0d67e0a16c627e7c67f754ce8ed4c4fb5b8d8b6
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/json.c b/src/json.c index ed43a5ce9..176dcbfdb 100644 --- a/src/json.c +++ b/src/json.c @@ -1272,8 +1272,30 @@ json_parse_restart: parse_string: cDelim = z[i]; for(j=i+1; 1; j++){ - unsigned char uc = (unsigned char)z[j]; - if( uc=='\\' ){ + static const char aOk[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + if( aOk[(unsigned char)z[j]] ) continue; + c = z[j]; + if( c==cDelim ){ + break; + }else if( c=='\\' ){ c = z[++j]; if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' || c=='n' || c=='r' || c=='t' @@ -1293,11 +1315,7 @@ json_parse_restart: pParse->iErr = j; return -1; } - }else if( uc>'\'' ){ - continue; - }else if( uc==cDelim ){ - break; - }else if( uc<=0x1f ){ + }else if( c<=0x1f ){ /* Control characters are not allowed in strings */ pParse->iErr = j; return -1; |