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 F091A70368; Fri, 29 Oct 2021 01:11:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F091A70368 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635459076; bh=T34/0cbdKTIZQeYccRPelVvo1VFvDoxvb1oyOT2yXhw=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=kELY/T0Zkkhfwnv/5q8yrWKKIcIqM6UbI9NcXm66Cc6UnNOyXqZ8vHuBMb5ZUMITe MZhIgmzrHopQ74y/IHdxGDajIx2JXgyWw6MFIE6KcUpxPMmgSnIF6jU226W/3TsXe0 hnxaNm5ACYX1HsUMXIHlc+WXbW5LVDaIgcE/dTtk= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 26E4770368 for ; Fri, 29 Oct 2021 01:11:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 26E4770368 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1mgDc8-0001Ky-Fp; Fri, 29 Oct 2021 01:11:12 +0300 Message-ID: Date: Fri, 29 Oct 2021 00:11:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Content-Language: en-US To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org References: <1243ff4d634abefca92dd265e81a64a4d347b56b.1633105483.git.imeevma@gmail.com> <4dd3b621-96a6-5c23-0c92-3a3cf0f398ee@tarantool.org> <20211020165216.GA203963@tarantool.org> In-Reply-To: <20211020165216.GA203963@tarantool.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9E6B4260954843F6F6CA2F287E066BD93F73BF403D6E2966600894C459B0CD1B94FBA091422E7C50DFFE8209CFBD0028B08357E0F7F63E000724492119CBD5D09 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7876E9C5582D2D91DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375FE8AD9F0D2764EB8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85C31183287607323AE46CD4D4352A959117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6CF11E2829993B7FCEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5959E762A13A70598D2E0A8999A6735737BFE2DA0AA610C55D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75C29D03FC76C37677410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3455049D7B43D89D64602487AFA957FD341FB64A3351BB76FB32DAFD730595452DC6E91431553AB1E71D7E09C32AA3244CBA2E5D78267C8A269E0FA21FEA21CCF28894E9C85370243E729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojdMRfVmNkPDiLSyElMXfU5A== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D4BDC27D65D651DB6BFE03897F1ED97EA3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/8] sql: refactor ABS() funcion 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the fixes! >>> + assert(mem_is_int(arg)); >>> + uint64_t u = mem_is_uint(arg) ? arg->u.u : (uint64_t)-arg->u.i; >> >> 2. You could make return when mem_is_uint(). It would remove '?' and >> mem_set_uint() which would calls mem_clear() inside. >> > I am not sure that I understood correctly. In case of argument being uint we > can use mem_copy_as_ephemeral() instead of mem_set_uint(), but I am not sure > if it would be better. I mean this: ==================== diff --git a/src/box/sql/func.c b/src/box/sql/func.c index dbeb38bee..2a848be31 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -239,11 +239,10 @@ func_abs_int(struct sql_context *ctx, int argc, struct Mem *argv) assert(argc == 1); (void)argc; struct Mem *arg = &argv[0]; - if (mem_is_null(arg)) + if (mem_is_null(arg) || mem_is_uint(arg)) return; assert(mem_is_int(arg)); - uint64_t u = mem_is_uint(arg) ? arg->u.u : (uint64_t)-arg->u.i; - mem_set_uint(ctx->pOut, u); + mem_set_uint(ctx->pOut, (uint64_t)-arg->u.i); } ==================== Up to you.