diff options
author | drh <> | 2023-07-27 00:21:59 +0000 |
---|---|---|
committer | drh <> | 2023-07-27 00:21:59 +0000 |
commit | 93853a48465e5eb14ab347eecc53f2b58a45ee02 (patch) | |
tree | 041431730f42add89849655a61eb3005d74f988d /src | |
parent | e94e132994e5144c39bbc68aa4a6180a3e60fd7a (diff) | |
download | sqlite-93853a48465e5eb14ab347eecc53f2b58a45ee02.tar.gz sqlite-93853a48465e5eb14ab347eecc53f2b58a45ee02.zip |
Fix a performance regression in JSON associated with generating small
snippets of JSON from a larger JSON string.
FossilOrigin-Name: 837f2907e10b026f6db1ca2d44b4bf60a6f069bf534bf369ad9b5c513cb0c6e4
Diffstat (limited to 'src')
-rw-r--r-- | src/json.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/json.c b/src/json.c index 24b3613e1..493a1b99c 100644 --- a/src/json.c +++ b/src/json.c @@ -563,12 +563,18 @@ static void jsonAppendValue( ** The JSON string is reset. */ static void jsonResult(JsonString *p){ - if( p->bErr==0 && jsonForceRCStr(p) ){ - sqlite3RCStrRef(p->zBuf); - sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, - (void(*)(void*))sqlite3RCStrUnref, - SQLITE_UTF8); - }else if( p->bErr==1 ){ + if( p->bErr==0 ){ + if( p->bStatic ){ + sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, + SQLITE_TRANSIENT, SQLITE_UTF8); + }else if( jsonForceRCStr(p) ){ + sqlite3RCStrRef(p->zBuf); + sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, + (void(*)(void*))sqlite3RCStrUnref, + SQLITE_UTF8); + } + } + if( p->bErr==1 ){ sqlite3_result_error_nomem(p->pCtx); } jsonReset(p); |