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 v2 3/3] sql: replace MEM-type flags by enum mem_type
Date: Fri, 21 May 2021 20:59:14 +0200 [thread overview]
Message-ID: <d3ac2493-847e-a3b3-751c-704d1a75063f@tarantool.org> (raw)
In-Reply-To: <20210517121811.GA177791@tarantool.org>
Hi! Thanks for the fixes!
See 2 small comments below.
> diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> index b6ff6397f..f7788021d 100644
> --- a/src/box/sql/mem.c
> +++ b/src/box/sql/mem.c
> @@ -1155,11 +1214,11 @@ mem_get_str0(const struct Mem *mem, const char **s)
> int
> mem_get_bin(const struct Mem *mem, const char **s)
> {
> - if ((mem->flags & MEM_Str) != 0) {
> + if (mem->type == MEM_TYPE_STR) {
> *s = mem->n > 0 ? mem->z : NULL;
> return 0;
> }
> - if ((mem->flags & MEM_Blob) == 0 || (mem->flags & MEM_Zero) != 0)
> + if (mem->type != MEM_TYPE_BIN || (mem->flags & MEM_Zero) != 0)
> return -1;
1. AFAIR, it is not possible to have MEM_Zero for non-bin. Which makes
the second condition unreachable, right? The same in mem_len().
> *s = mem->z;
> return 0;
> @@ -1644,14 +1717,15 @@ mem_bit_not(const struct Mem *mem, struct Mem *result)
> return -1;
> }
> result->u.i = ~i;
> - result->flags = result->u.i < 0 ? MEM_Int : MEM_UInt;
> + result->type = result->u.i < 0 ? MEM_TYPE_INT : MEM_TYPE_UINT;
> + assert(result->flags == 0);
> return 0;
> }
>
> int
> mem_cmp_bool(const struct Mem *a, const struct Mem *b, int *result)
> {
> - if ((a->flags & b->flags & MEM_Bool) == 0)
> + if (a->type != MEM_TYPE_BOOL || b->type != MEM_TYPE_BOOL)
2. You could leave the old way so as to avoid || (branching).
> return -1;
> if (a->u.b == b->u.b)
> *result = 0;
next prev parent reply other threads:[~2021-05-21 18:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 16:55 [Tarantool-patches] [PATCH v2 0/3] Replace " Mergen Imeev via Tarantool-patches
2021-04-27 16:55 ` [Tarantool-patches] [PATCH v2 3/3] sql: replace " Mergen Imeev via Tarantool-patches
2021-04-29 21:09 ` Vladislav Shpilevoy via Tarantool-patches
2021-05-17 12:18 ` Mergen Imeev via Tarantool-patches
2021-05-17 12:34 ` Mergen Imeev via Tarantool-patches
2021-05-21 18:59 ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-05-24 10:56 ` Mergen Imeev via Tarantool-patches
2021-05-24 15:26 ` Vladislav Shpilevoy via Tarantool-patches
2021-05-25 11:13 ` Mergen Imeev via Tarantool-patches
2021-05-25 21:33 ` [Tarantool-patches] [PATCH v2 0/3] Replace " Vladislav Shpilevoy via Tarantool-patches
2021-05-26 8:06 ` Kirill Yukhin 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=d3ac2493-847e-a3b3-751c-704d1a75063f@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=imeevma@tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 3/3] sql: replace MEM-type flags by enum mem_type' \
/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