From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 29F2245C304 for ; Thu, 10 Dec 2020 20:17:04 +0300 (MSK) Date: Thu, 10 Dec 2020 17:17:02 +0000 From: Nikita Pettik Message-ID: <20201210171702.GC1319@tarantool.org> References: <5b3a70820a00cdfa26189933a4ae0549a0398c72.1607075291.git.sergepetrenko@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5b3a70820a00cdfa26189933a4ae0549a0398c72.1607075291.git.sergepetrenko@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v3 1/2] box: speed up tuple_field_map_create List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org 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; > +} > +