[tarantool-patches] Re: [PATCH v2 3/8] sql: wrap all trim functions in dispatcher

n.pettik korablev at tarantool.org
Fri Aug 9 21:05:25 MSK 2019



> On 8 Aug 2019, at 17:50, Kirill Shcherbatov <kshcherbatov at tarantool.org> wrote:
> 
> A new dispatcher function trim_func calls corresponding trim_
> function implementation in relation with number of argc - a count
> of arguments.
> 
> This is an important stem to get rid of function's name

Nit: stem -> step

> overloading required for replace FuncDef cache with Tarantool's
> function cache.
> 
> Needed for #2200, #4113, #2233
> ---
> src/box/sql/func.c | 32 +++++++++++++++++++++++++++++---
> 1 file changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index e00764c3f..f9c0a819e 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -1496,6 +1496,32 @@ trim_func_three_args(struct sql_context *context, int argc, sql_value **argv)
> 		       char_cnt, input_str, input_str_sz);
> 	sql_free(char_len);
> }
> +
> +/**
> + * Normalize args from @a argv input array when it has one,
> + * two or three args.
> + *
> + * This is a dispatcher function that call corresponding

Nit: call -> calls

> + * implementation depending on the number of arguments.
> +*/
> +static void
> +trim_func(struct sql_context *context, int argc, sql_value **argv)
> +{
> +	switch (argc) {
> +	case 1:
> +		trim_func_one_arg(context, argc, argv);

Why not unpack arguments right here?
IMHO it would look much better.





More information about the Tarantool-patches mailing list