[Tarantool-patches] [PATCH v2 13/15] sql: remove copying of result in finalizers
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Thu Sep 23 01:50:40 MSK 2021
Thanks for the fixes!
> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
> index 8804e3d18..65bb60d2f 100644
> --- a/src/box/sql/vdbe.c
> +++ b/src/box/sql/vdbe.c
> @@ -4207,24 +4200,10 @@ case OP_AggFinal: {
> struct func_sql_builtin *func = (struct func_sql_builtin *)pOp->p4.func;
> struct Mem *pIn1 = &aMem[pOp->p1];
>
> - struct sql_context ctx;
> - memset(&ctx, 0, sizeof(ctx));
> - struct Mem t;
> - memset(&t, 0, sizeof(t));
> - t.type = MEM_TYPE_NULL;
> - assert(t.flags == 0);
> - t.db = pIn1->db;
> - ctx.pOut = &t;
> - ctx.pMem = pIn1;
> - ctx.func = pOp->p4.func;
> - func->finalize(&ctx);
> - assert((pIn1->flags & MEM_Dyn) == 0);
> - if (pIn1->szMalloc > 0)
> - sqlDbFree(pIn1->db, pIn1->zMalloc);
> - memcpy(pIn1, &t, sizeof(t));
> -
> - if (ctx.is_aborted)
> - goto abort_due_to_error;
> + if (func->finalize != NULL) {
> + if (func->finalize(pIn1) != 0)
Such places might look simpler and shorter if you would
use &&:
if (func->finalize != NULL && func->finalize(...
Up to you.
More information about the Tarantool-patches
mailing list