From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Mergen Imeev <imeevma@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v1 2/7] sql: remove implicit cast from comparison opcodes
Date: Fri, 6 Aug 2021 02:13:31 +0200 [thread overview]
Message-ID: <04f59078-e7bd-56f7-5999-3080b54299f4@tarantool.org> (raw)
In-Reply-To: <20210805233339.GB81912@tarantool.org>
>>> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
>>> index d143ce364..62f58def9 100644
>>> --- a/src/box/sql/vdbe.c
>>> +++ b/src/box/sql/vdbe.c
>> <...>
>>
>>> - switch( pOp->opcode) {
>>> - case OP_Eq: res2 = res==0; break;
>>> - case OP_Ne: res2 = res; break;
>>> - case OP_Lt: res2 = res<0; break;
>>> - case OP_Le: res2 = res<=0; break;
>>> - case OP_Gt: res2 = res>0; break;
>>> - default: res2 = res>=0; break;
>>> + bool result;
>>> + switch(pOp->opcode) {
>>
>> 3. It does not look good to have a second switch-case here. But I
>> can't find a better solution right away. We can't wrap this all
>> into a function, because need to make goto abort_due_to_error and
>> goto jump_to_p2 in some places. Up to you if you want to find a
>> way to fix it.
>>
>> As a side note, the code now is incomparably simpler than it was.
>> It is getting actually understable, nice.
>>
> I divided these 6 opcode to two grops: EQ & NE and all others. ALso, I actually
> can avoid branching in any groups using somethins like:
>
> int op = pOp->opcode;
> bool result = (op == OP_Lt && cmp_res < 0) || (op == OP_Gt && cmp_res > 0) || ...
> But not sure that it will be easier to read. What do you think?
That is still branching - && and || are not better than 'if' usually.
Up to you.
next prev parent reply other threads:[~2021-08-06 0:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 20:51 [Tarantool-patches] [PATCH v1 0/7] Rework implicit cast Mergen Imeev via Tarantool-patches
2021-07-28 20:51 ` [Tarantool-patches] [PATCH v1 1/7] sql: rework implicit cast fo assignment Mergen Imeev via Tarantool-patches
2021-07-30 21:55 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-04 22:21 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-05 23:27 ` Mergen Imeev via Tarantool-patches
2021-08-06 0:13 ` Vladislav Shpilevoy via Tarantool-patches
2021-07-28 20:51 ` [Tarantool-patches] [PATCH v1 2/7] sql: remove implicit cast from comparison opcodes Mergen Imeev via Tarantool-patches
2021-08-04 22:24 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-05 23:33 ` Mergen Imeev via Tarantool-patches
2021-08-06 0:13 ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-07-28 20:51 ` [Tarantool-patches] [PATCH v1 3/7] sql: rework OP_Seek* opcodes Mergen Imeev via Tarantool-patches
2021-08-04 22:25 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-05 23:40 ` Mergen Imeev via Tarantool-patches
2021-07-28 20:51 ` [Tarantool-patches] [PATCH v1 4/7] sql: remove unnecessary calls of OP_ApplyType Mergen Imeev via Tarantool-patches
2021-08-04 22:26 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-05 23:41 ` Mergen Imeev via Tarantool-patches
2021-07-28 20:51 ` [Tarantool-patches] [PATCH v1 5/7] sql: remove implicit cast from OP_MakeRecord Mergen Imeev via Tarantool-patches
2021-08-04 22:27 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-05 23:43 ` Mergen Imeev via Tarantool-patches
2021-08-06 0:13 ` Vladislav Shpilevoy via Tarantool-patches
2021-07-28 20:51 ` [Tarantool-patches] [PATCH v1 6/7] sql: remove implicit cast from OP_MustBeInt Mergen Imeev via Tarantool-patches
2021-08-05 23:47 ` Mergen Imeev via Tarantool-patches
2021-07-28 20:51 ` [Tarantool-patches] [PATCH v1 7/7] sql: remove unused MEM cast functions Mergen Imeev via Tarantool-patches
2021-08-04 22:27 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-05 23:45 ` Mergen Imeev via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=04f59078-e7bd-56f7-5999-3080b54299f4@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=imeevma@tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v1 2/7] sql: remove implicit cast from comparison opcodes' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox