[Tarantool-patches] [PATCH v1 14/21] sql: refactor UNICODE() function
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Fri Oct 15 01:44:37 MSK 2021
Thanks for the patch!
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index fb7fd772e..5e12ef729 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -1007,6 +1007,19 @@ func_version(struct sql_context *ctx, int argc, struct Mem *argv)
> return mem_set_str0_static(ctx->pOut, (char *)tarantool_version());
> }
>
> +/** Implementation of the UNICODE() function. */
> +static void
> +func_unicode(struct sql_context *ctx, int argc, struct Mem *argv)
> +{
> + assert(argc == 1);
> + (void)argc;
> + if (mem_is_null(&argv[0]))
> + return;
> + assert(mem_is_str(&argv[0]));
> + const char *str = tt_cstr(argv[0].z, argv[0].n);
> + mem_set_uint(ctx->pOut, sqlUtf8Read((const unsigned char **)&str));
You can dodge the copying. See utf8_next() in utf8.c:
UChar32 c;
U8_NEXT(str, pos, len, c);
More information about the Tarantool-patches
mailing list