From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 1B51F68F40; Tue, 23 Mar 2021 12:48:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1B51F68F40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616492898; bh=eFnE1Y7qd99CRq0c4Iej19B53mrvW9UpdIBL+Mhlbpg=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=QmpZxyHMnK44si0P5BIUDhcYngepzymoj1d4pGZlRPSd3+xn6q0rCIVYI+EmAqHWF tJQbKKH8shPhRidmKQS7KaHEo0+ZiPIS6dhg/OJ3PZlEXiTiuoeZuUm4AEnzzZ5irz RCQQxEa1zdvw4Z6MAilPSpHeS8L1ihWBYIcx4NJQ= Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (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 C484768F50 for ; Tue, 23 Mar 2021 12:35:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C484768F50 Received: by smtp60.i.mail.ru with esmtpa (envelope-from ) id 1lOdS6-0004Ji-1D; Tue, 23 Mar 2021 12:35:54 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Tue, 23 Mar 2021 12:35:53 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD95D6E7CC48CB1F5F1DDD90A25A8FA528D0BFD61B598B81272182A05F538085040E2869B0212656778A00FF7B4941E6B21BC0249B5CC200EBF075D539EBF4F99BD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73B44982FA5E78411EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F97367C191A19EB28638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C686AF563A045C75E17A878B56A83F7C8D0C2DEC7D4B0AF77A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE703ECDEEEF9F1DA999FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C35C5DFC4BFF39B799CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249EF4EC40CFC69163A76E601842F6C81A12EF20D2F80756B5F7E9C4E3C761E06A776E601842F6C81A127C277FBC8AE2E8B5AB25D3CD3EDABF53AA81AA40904B5D9DBF02ECDB25306B2201CA6A4E26CD07C3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B091A620F70A64A45A99449624AB7ADAF3735872C767BF85DA29E625A9149C048EE0A3850AC1BE2E7356436AE5DD6441DC74AD6D5ED66289B524E70A05D1297E1BB35872C767BF85DA227C277FBC8AE2E8B56969FF77163EA2B75ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC85D9B7C4F32B44FF57D4B828FA1BC0F1ACBD9CCCA9EDD067B1EDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24A6D60772A99906F8E1CD14B953EB46DB47F74294F456821355D89D7DBCDD132 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C686AF563A045C75E17A878B56A83F7C8D0C2DEC7D4B0AF779C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34411AA3F52B5778B6157CF3F79BC2D6F509DBE993995EF3978FE8E773506A7F54CA81F35D625D2B821D7E09C32AA3244C223B80034021A6BEAE57F238EB44B84E725D5B54B2FE4575FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWJZv20R+6UhnjszZB33h9A== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306ED790E4345BDA944E7A00FF7B4941E6B21DDEE725E12766E675105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF7402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 27/53] sql: refactor mem_set_double() X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch introduces mem_set_double(). Function mem_set_double() clears MEM and sets it to given unsigned value. Part of #5818 --- src/box/sql/mem.c | 22 +++++++++++----------- src/box/sql/mem.h | 7 +++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index 42a65d714..47a71fb30 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -290,6 +290,17 @@ mem_set_boolean(struct Mem *mem, bool value) mem->field_type = FIELD_TYPE_BOOLEAN; } +void +mem_set_double(struct Mem *mem, double value) +{ + mem_clear(mem); + mem->field_type = FIELD_TYPE_DOUBLE; + if (sqlIsNaN(value)) + return; + mem->u.r = value; + mem->flags = MEM_Real; +} + int mem_copy(struct Mem *to, const struct Mem *from) { @@ -1916,17 +1927,6 @@ mem_set_ptr(struct Mem *mem, void *ptr) mem->u.p = ptr; } -void -mem_set_double(struct Mem *mem, double value) -{ - mem_clear(mem); - if (sqlIsNaN(value)) - return; - mem->u.r = value; - MemSetTypeFlag(mem, MEM_Real); - mem->field_type = FIELD_TYPE_DOUBLE; -} - /* * Change the value of a Mem to be a string or a BLOB. * diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h index bf3690b7c..49b4e4b1a 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -179,6 +179,9 @@ mem_set_unsigned(struct Mem *mem, uint64_t value); void mem_set_boolean(struct Mem *mem, bool value); +void +mem_set_double(struct Mem *mem, double value); + /** * Copy content of MEM from one MEM to another. In case source MEM contains * string or binary and allocation type is not STATIC, this value is copied to @@ -419,10 +422,6 @@ int sqlVdbeMemClearAndResize(struct Mem * pMem, int n); void mem_set_ptr(struct Mem *mem, void *ptr); -/** Set double value and MEM_Real flag. */ -void -mem_set_double(struct Mem *mem, double value); - int sqlVdbeMemSetStr(struct Mem *, const char *, int, u8, void (*)(void *)); void -- 2.25.1