mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Avoid some pnstrdup()s when constructing jsonb
This speeds up text to jsonb parsing and hstore to jsonb conversions somewhat.
This commit is contained in:
@@ -381,9 +381,6 @@ parse_object_field(JsonLexContext *lex, JsonSemAction *sem)
|
||||
|
||||
if (oend != NULL)
|
||||
(*oend) (sem->semstate, fname, isnull);
|
||||
|
||||
if (fname != NULL)
|
||||
pfree(fname);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -247,7 +247,7 @@ jsonb_in_object_field_start(void *pstate, char *fname, bool isnull)
|
||||
Assert(fname != NULL);
|
||||
v.type = jbvString;
|
||||
v.val.string.len = checkStringLen(strlen(fname));
|
||||
v.val.string.val = pnstrdup(fname, v.val.string.len);
|
||||
v.val.string.val = fname;
|
||||
|
||||
_state->res = pushJsonbValue(&_state->parseState, WJB_KEY, &v);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ jsonb_in_scalar(void *pstate, char *token, JsonTokenType tokentype)
|
||||
Assert(token != NULL);
|
||||
v.type = jbvString;
|
||||
v.val.string.len = checkStringLen(strlen(token));
|
||||
v.val.string.val = pnstrdup(token, v.val.string.len);
|
||||
v.val.string.val = token;
|
||||
break;
|
||||
case JSON_TOKEN_NUMBER:
|
||||
|
||||
|
@@ -73,6 +73,10 @@ typedef void (*json_scalar_action) (void *state, char *token, JsonTokenType toke
|
||||
* point, Likewise, semstate can be NULL. Using an all-NULL structure amounts
|
||||
* to doing a pure parse with no side-effects, and is therefore exactly
|
||||
* what the json input routines do.
|
||||
*
|
||||
* The 'fname' and 'token' strings passed to these actions are palloc'd.
|
||||
* They are not free'd or used further by the parser, so the action function
|
||||
* is free to do what it wishes with them.
|
||||
*/
|
||||
typedef struct JsonSemAction
|
||||
{
|
||||
|
Reference in New Issue
Block a user