[Tarantool-patches] [PATCH v3 1/2] box: speed up tuple_field_map_create

Nikita Pettik korablev at tarantool.org
Thu Dec 10 20:17:02 MSK 2020


On 04 Dec 12:52, Serge Petrenko wrote:
> +static int
> +tuple_field_map_create_plain(struct tuple_format *format, const char *tuple,
> +			     bool validate, struct field_map_builder *builder)
> +{
> +	struct region *region = &fiber()->gc;
> +	const char *pos = tuple;
> +	uint32_t defined_field_count = mp_decode_array(&pos);
> +	if (validate && format->exact_field_count > 0 &&
> +	    format->exact_field_count != defined_field_count) {
> +		diag_set(ClientError, ER_EXACT_FIELD_COUNT,
> +			 (unsigned) defined_field_count,
> +			 (unsigned) format->exact_field_count);
> +		return -1;
> +	}
> +	defined_field_count = MIN(defined_field_count,

I'd rewrite this part as:

diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c
index 6c9b2a255..d6655256a 100644
--- a/src/box/tuple_format.c
+++ b/src/box/tuple_format.c
@@ -912,10 +912,12 @@ tuple_field_map_create_plain(struct tuple_format *format, const char *tuple,
        }
 
 end:
-       return validate ?
-              tuple_format_required_fields_validate(format, required_fields,
-                                                    required_fields_sz) :
-              0;
+       if (validate) {
+               return tuple_format_required_fields_validate(format,
+                                                            required_fields,
+                                                            required_fields_sz);
+       }
+       return 0;
 }
 

Up to you. Anyway LGTM

> +end:
> +	return validate ?
> +	       tuple_format_required_fields_validate(format, required_fields,
> +						     required_fields_sz) :
> +	       0;
> +}
> +


More information about the Tarantool-patches mailing list