[Tarantool-patches] [PATCH v4 41/53] sql: introduce mem_convert_to_integer()
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Tue Mar 30 02:07:29 MSK 2021
Thanks for the patch!
See 2 comments below.
On 23.03.2021 10:36, imeevma at tarantool.org wrote:
> This patch introduces mem_convert_to_integer() which is used to convert
> a MEM to a MEM that contains integer value.
>
> Part of #5818
> ---
> src/box/sql/mem.c | 114 +++++++++++++++++++++++++++++----------------
> src/box/sql/mem.h | 7 ++-
> src/box/sql/vdbe.c | 19 ++++----
> 3 files changed, 88 insertions(+), 52 deletions(-)
>
> diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> index 1209df1ce..b9bcd3d3a 100644
> --- a/src/box/sql/mem.c
> +++ b/src/box/sql/mem.c
> @@ -695,6 +695,80 @@ mem_set_cleared(struct Mem *mem)
<...>
> +
> +static inline int
> +mem_convert_double_to_integer_lossless(struct Mem *mem)
1. Lets use 'precise'. Here and in other places. And shorten
the names. So it would be mem_convert_bool_to_int(),
mem_convert_to_int(), etc.
> +{
> + double d = mem->u.r;
> + if (d < 0 && d >= (double)INT64_MIN && (double)(int64_t)d == d) {
> + mem_set_integer(mem, (int64_t)d, true);
> + return 0;
> + }
> + if (d >= 0 && d < (double)UINT64_MAX && (double)(uint64_t)d == d) {
> + mem_set_integer(mem, (int64_t)(uint64_t)d, false);
2. Isn't mem_set_unsigned() faster? Or we can't set FIELD_TYPE_UNSIGNED?
More information about the Tarantool-patches
mailing list