mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Performance optimization for parsing large JSONs that contain lots of text.
FossilOrigin-Name: c9fbe0185cd5d64950724b00cd0bfb3a7939a985040465a0f35f445acb6e94a6
This commit is contained in:
21
src/json.c
21
src/json.c
@@ -1235,15 +1235,9 @@ json_parse_restart:
|
||||
jnFlags = 0;
|
||||
parse_string:
|
||||
cDelim = z[i];
|
||||
j = i+1;
|
||||
for(;;){
|
||||
c = z[j];
|
||||
if( (c & ~0x1f)==0 ){
|
||||
/* Control characters are not allowed in strings */
|
||||
pParse->iErr = j;
|
||||
return -1;
|
||||
}
|
||||
if( c=='\\' ){
|
||||
for(j=i+1; 1; j++){
|
||||
unsigned char uc = (unsigned char)z[j];
|
||||
if( uc=='\\' ){
|
||||
c = z[++j];
|
||||
if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f'
|
||||
|| c=='n' || c=='r' || c=='t'
|
||||
@@ -1263,10 +1257,15 @@ json_parse_restart:
|
||||
pParse->iErr = j;
|
||||
return -1;
|
||||
}
|
||||
}else if( c==cDelim ){
|
||||
}else if( uc>'\'' ){
|
||||
continue;
|
||||
}else if( uc==cDelim ){
|
||||
break;
|
||||
}else if( uc<=0x1f ){
|
||||
/* Control characters are not allowed in strings */
|
||||
pParse->iErr = j;
|
||||
return -1;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
jsonParseAddNode(pParse, JSON_STRING | (jnFlags<<8), j+1-i, &z[i]);
|
||||
return j+1;
|
||||
|
||||
Reference in New Issue
Block a user