From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 69FE846971A for ; Mon, 9 Dec 2019 16:34:15 +0300 (MSK) From: imeevma@tarantool.org Date: Mon, 9 Dec 2019 16:34:14 +0300 Message-Id: <381277456f80b14128a4b22657e1ee03c8611435.1575898091.git.imeevma@gmail.com> In-Reply-To: References: Subject: [Tarantool-patches] [PATCH v3 1/2] sql: refactor sqlVdbeMemIntegerify() function List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: korablev@tarantool.org Cc: tarantool-patches@dev.tarantool.org The sqlVdbeMemIntegerify() function accepts the is_forced flag as one of the arguments. But this flag is actually useless, because regardless of whether it is TRUE or FALSE, the function will do the same. This patch removes the is_forced argument from the function. There will be no test, since the result of the function has not changed. Part of #4526 --- src/box/sql/vdbe.c | 2 +- src/box/sql/vdbeInt.h | 2 +- src/box/sql/vdbemem.c | 9 ++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index ab86be9..8ea1df8 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -328,7 +328,7 @@ mem_apply_type(struct Mem *record, enum field_type type) record->u.r <= -1); return 0; } - if (sqlVdbeMemIntegerify(record, false) != 0) + if (sqlVdbeMemIntegerify(record) != 0) return -1; if ((record->flags & MEM_Int) == MEM_Int) { if (type == FIELD_TYPE_UNSIGNED) diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index 0f32b4c..d70f683 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -506,7 +506,7 @@ int sqlVdbeMemMakeWriteable(Mem *); int sqlVdbeMemStringify(Mem *); int sqlVdbeIntValue(Mem *, int64_t *, bool *is_neg); -int sqlVdbeMemIntegerify(Mem *, bool is_forced); +int sqlVdbeMemIntegerify(struct Mem *pMem); int sqlVdbeRealValue(Mem *, double *); int diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index 2d37b62..e2e2b7a 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -554,7 +554,7 @@ mem_apply_integer_type(Mem *pMem) * Convert pMem to type integer. Invalidate any prior representations. */ int -sqlVdbeMemIntegerify(Mem * pMem, bool is_forced) +sqlVdbeMemIntegerify(struct Mem *pMem) { assert(EIGHT_BYTE_ALIGNMENT(pMem)); @@ -563,11 +563,6 @@ sqlVdbeMemIntegerify(Mem * pMem, bool is_forced) if (sqlVdbeIntValue(pMem, &i, &is_neg) == 0) { mem_set_int(pMem, i, is_neg); return 0; - } else if ((pMem->flags & MEM_Real) != 0 && is_forced) { - if (pMem->u.r >= INT64_MAX || pMem->u.r < INT64_MIN) - return -1; - mem_set_int(pMem, pMem->u.r, pMem->u.r <= -1); - return 0; } double d; @@ -735,7 +730,7 @@ sqlVdbeMemCast(Mem * pMem, enum field_type type) MemSetTypeFlag(pMem, MEM_UInt); return 0; } - if (sqlVdbeMemIntegerify(pMem, true) != 0) + if (sqlVdbeMemIntegerify(pMem) != 0) return -1; if (type == FIELD_TYPE_UNSIGNED && (pMem->flags & MEM_UInt) == 0) -- 2.7.4