1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +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:
Heikki Linnakangas
2014-05-09 11:32:28 +03:00
parent 14d309cc55
commit d3c72e23df
4 changed files with 10 additions and 9 deletions

View File

@ -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

View File

@ -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: