Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8ea2d2b

Browse files
author
Nikita Glukhov
committed
Optimize JsonToJsonValue() for jsonv containers
1 parent 9951a7b commit 8ea2d2b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/backend/utils/adt/json_generic.c

+3
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ jsonvContainerOps =
562562
JsonValue *
563563
JsonToJsonValue(Json *json, JsonValue *jv)
564564
{
565+
if (JsonRoot(json)->ops == &jsonvContainerOps)
566+
return (JsonValue *) JsonRoot(json)->data;
567+
565568
if (!jv)
566569
jv = palloc(sizeof(JsonValue));
567570

src/backend/utils/adt/jsonb.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,11 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result,
862862
{
863863
JsonbIteratorToken type;
864864

865-
JsonToJsonValue(jsonb, &jb);
866865

867866
if (result->parseState)
868867
{
869-
pushScalarJsonbValue(&result->parseState, &jb,
868+
pushScalarJsonbValue(&result->parseState,
869+
JsonToJsonValue(jsonb, &jb),
870870
false, false);
871871
return;
872872
}

0 commit comments

Comments
 (0)