From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id D050727322 for ; Fri, 8 Feb 2019 07:52:40 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q6wR6MaIYM2o for ; Fri, 8 Feb 2019 07:52:40 -0500 (EST) Received: from smtp46.i.mail.ru (smtp46.i.mail.ru [94.100.177.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id E87D926CCE for ; Fri, 8 Feb 2019 07:52:39 -0500 (EST) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v1 3/4] sql: got rid of redundant MASKBIT32 definition Date: Fri, 8 Feb 2019 15:52:27 +0300 Message-Id: <4330bedcb868e7f44185f1179bb5e9c2e46a78c5.1549629707.git.kshcherbatov@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org Cc: Kirill Shcherbatov MASK BIT 32 macro is now redundant, so we got rid of it. Also refactored related code to use core bitmasks helpers Part of #3571 --- src/box/sql/expr.c | 22 ++++++++++++---------- src/box/sql/sqliteInt.h | 1 - src/box/sql/vdbeaux.c | 7 +++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c index d83be5101..cf82bd366 100644 --- a/src/box/sql/expr.c +++ b/src/box/sql/expr.c @@ -3963,7 +3963,11 @@ sqlite3ExprCodeTarget(Parse * pParse, Expr * pExpr, int target) int nFarg; /* Number of function arguments */ FuncDef *pDef; /* The function definition object */ const char *zId; /* The function name */ - u32 constMask = 0; /* Mask of function arguments that are constant */ + /* + * Mask of function arguments that are + * constant. + */ + uint32_t const_mask = 0; int i; /* Loop counter */ sqlite3 *db = pParse->db; /* The database connection */ struct coll *coll = NULL; @@ -4038,11 +4042,10 @@ sqlite3ExprCodeTarget(Parse * pParse, Expr * pExpr, int target) } for (i = 0; i < nFarg; i++) { - if (i < 32 - && sqlite3ExprIsConstant(pFarg->a[i]. - pExpr)) { - testcase(i == 31); - constMask |= MASKBIT32(i); + if (i < 32 && + sqlite3ExprIsConstant(pFarg->a[i].pExpr)) { + column_mask_set_fieldno((uint64_t *) + &const_mask, i); } if ((pDef->funcFlags & SQLITE_FUNC_NEEDCOLL) != 0 && coll == NULL) { @@ -4054,7 +4057,7 @@ sqlite3ExprCodeTarget(Parse * pParse, Expr * pExpr, int target) } } if (pFarg) { - if (constMask) { + if (const_mask != 0) { r1 = pParse->nMem + 1; pParse->nMem += nFarg; } else { @@ -4102,12 +4105,11 @@ sqlite3ExprCodeTarget(Parse * pParse, Expr * pExpr, int target) sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)coll, P4_COLLSEQ); } - sqlite3VdbeAddOp4(v, OP_Function0, constMask, r1, + sqlite3VdbeAddOp4(v, OP_Function0, const_mask, r1, target, (char *)pDef, P4_FUNCDEF); sqlite3VdbeChangeP5(v, (u8) nFarg); - if (nFarg && constMask == 0) { + if (nFarg && const_mask == 0) sqlite3ReleaseTempRange(pParse, r1, nFarg); - } return target; } case TK_EXISTS: diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index 4280c1938..913d3f9ac 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -2307,7 +2307,6 @@ typedef u64 Bitmask; * A bit in a Bitmask */ #define MASKBIT(n) (((Bitmask)1)<<(n)) -#define MASKBIT32(n) (((unsigned int)1)<<(n)) #define ALLBITS ((Bitmask)-1) /* diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index 975f114df..af57c244b 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -2698,10 +2698,9 @@ sqlite3VdbeDeleteAuxData(sqlite3 * db, AuxData ** pp, int iOp, int mask) { while (*pp) { AuxData *pAux = *pp; - if ((iOp < 0) - || (pAux->iOp == iOp - && (pAux->iArg > 31 || !(mask & MASKBIT32(pAux->iArg)))) - ) { + if (iOp < 0 || (pAux->iOp == iOp && + (pAux->iArg >= 32 || + (mask & COLUMN_MASK_BIT(pAux->iArg)) == 0))) { testcase(pAux->iArg == 31); if (pAux->xDelete) { pAux->xDelete(pAux->pAux); -- 2.20.1