Skip to content

Commit bb513b3

Browse files
committed
Get rid of unnecessary memory allocation in jsonb_subscript_assign()
Current code allocates memory for JsonbValue, but it could be placed locally.
1 parent fe61df7 commit bb513b3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/backend/utils/adt/jsonbsubs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ jsonb_subscript_assign(ExprState *state,
283283
*/
284284
if (*op->resnull)
285285
{
286-
JsonbValue *newSource = (JsonbValue *) palloc(sizeof(JsonbValue));
286+
JsonbValue newSource;
287287

288288
/*
289289
* To avoid any surprising results, set up an empty jsonb array in
@@ -292,17 +292,17 @@ jsonb_subscript_assign(ExprState *state,
292292
*/
293293
if (workspace->expectArray)
294294
{
295-
newSource->type = jbvArray;
296-
newSource->val.array.nElems = 0;
297-
newSource->val.array.rawScalar = false;
295+
newSource.type = jbvArray;
296+
newSource.val.array.nElems = 0;
297+
newSource.val.array.rawScalar = false;
298298
}
299299
else
300300
{
301-
newSource->type = jbvObject;
302-
newSource->val.object.nPairs = 0;
301+
newSource.type = jbvObject;
302+
newSource.val.object.nPairs = 0;
303303
}
304304

305-
jsonbSource = JsonbValueToJsonb(newSource);
305+
jsonbSource = JsonbValueToJsonb(&newSource);
306306
*op->resnull = false;
307307
}
308308
else

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy