diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2021-02-01 14:06:02 +0300 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2021-02-01 14:06:02 +0300 |
commit | bb513b364b4fe31574574c8d0afbb2255268b321 (patch) | |
tree | 22466321000ba1185e43e729b3898ffb873c5815 /src/backend/utils/adt/jsonbsubs.c | |
parent | fe61df7f82aa6e0879476146dbe1da9c89b4946b (diff) | |
download | postgresql-bb513b364b4fe31574574c8d0afbb2255268b321.tar.gz postgresql-bb513b364b4fe31574574c8d0afbb2255268b321.zip |
Get rid of unnecessary memory allocation in jsonb_subscript_assign()
Current code allocates memory for JsonbValue, but it could be placed locally.
Diffstat (limited to 'src/backend/utils/adt/jsonbsubs.c')
-rw-r--r-- | src/backend/utils/adt/jsonbsubs.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/utils/adt/jsonbsubs.c b/src/backend/utils/adt/jsonbsubs.c index cfb923aaa35..5868aad0578 100644 --- a/src/backend/utils/adt/jsonbsubs.c +++ b/src/backend/utils/adt/jsonbsubs.c @@ -283,7 +283,7 @@ jsonb_subscript_assign(ExprState *state, */ if (*op->resnull) { - JsonbValue *newSource = (JsonbValue *) palloc(sizeof(JsonbValue)); + JsonbValue newSource; /* * To avoid any surprising results, set up an empty jsonb array in @@ -292,17 +292,17 @@ jsonb_subscript_assign(ExprState *state, */ if (workspace->expectArray) { - newSource->type = jbvArray; - newSource->val.array.nElems = 0; - newSource->val.array.rawScalar = false; + newSource.type = jbvArray; + newSource.val.array.nElems = 0; + newSource.val.array.rawScalar = false; } else { - newSource->type = jbvObject; - newSource->val.object.nPairs = 0; + newSource.type = jbvObject; + newSource.val.object.nPairs = 0; } - jsonbSource = JsonbValueToJsonb(newSource); + jsonbSource = JsonbValueToJsonb(&newSource); *op->resnull = false; } else |