SQLite

Check-in [837f2907]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a performance regression in JSON associated with generating small snippets of JSON from a larger JSON string. See forum thread 15d6bd9cd37202a7.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 837f2907e10b026f6db1ca2d44b4bf60a6f069bf534bf369ad9b5c513cb0c6e4
User & Date: drh 2023-07-27 00:21:59
Original Comment: Fix a performance regression in JSON associated with generating small snippets of JSON from a larger JSON string.
Context
2023-07-27
01:38
Accommodate a breaking change in emcc 3.1.44. (check-in: 2c5dd341 user: stephan tags: trunk)
00:21
Fix a performance regression in JSON associated with generating small snippets of JSON from a larger JSON string. See forum thread 15d6bd9cd37202a7. (check-in: 837f2907 user: drh tags: trunk)
2023-07-26
23:22
Reduce the number of memory allocations when parsing JSON. (check-in: 9edd6716 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/json.c.
559
560
561
562
563
564
565
566




567
568
569
570


571
572
573
574
575
576
577
578


/* Make the JSON in p the result of the SQL function.
**
** 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 ){
    sqlite3_result_error_nomem(p->pCtx);
  }
  jsonReset(p);
}

/**************************************************************************
** Utility routines for dealing with JsonNode and JsonParse objects







|
>
>
>
>
|
|
|
|
>
>
|







559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584


/* Make the JSON in p the result of the SQL function.
**
** The JSON string is reset.
*/
static void jsonResult(JsonString *p){
  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);
}

/**************************************************************************
** Utility routines for dealing with JsonNode and JsonParse objects