Skip to content

Commit c185ef4

Browse files
author
Commitfest Bot
committed
[CF 6000] v2 - Optimize JsonbContainerTypeName by reordering type checks
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/6000 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CAEoWx2n25k=amT2u_KY+Dk-UmV8GZiHfx=qpmh0RC=PTbAO+nA@mail.gmail.com Author(s): Chao Li
2 parents a95e3d8 + b9ee2d6 commit c185ef4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backend/utils/adt/jsonb.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ JsonbContainerTypeName(JsonbContainer *jbc)
160160
{
161161
JsonbValue scalar;
162162

163-
if (JsonbExtractScalar(jbc, &scalar))
164-
return JsonbTypeName(&scalar);
165-
else if (JsonContainerIsArray(jbc))
166-
return "array";
167-
else if (JsonContainerIsObject(jbc))
163+
if (JsonContainerIsObject(jbc))
168164
return "object";
165+
else if (!JsonContainerIsScalar(jbc) && JsonContainerIsArray(jbc))
166+
return "array";
167+
else if (JsonbExtractScalar(jbc, &scalar))
168+
return JsonbTypeName(&scalar);
169169
else
170170
{
171171
elog(ERROR, "invalid jsonb container type: 0x%08x", jbc->header);

0 commit comments

Comments
 (0)