Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbb513b3

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 parentfe61df7 commitbb513b3

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+
JsonbValuenewSource;
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)

[8]ページ先頭

©2009-2025 Movatter.jp