From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id EB44425337 for ; Mon, 12 Aug 2019 19:02:54 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 94TQVcwpRbGA for ; Mon, 12 Aug 2019 19:02:54 -0400 (EDT) Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id ABA3425308 for ; Mon, 12 Aug 2019 19:02:54 -0400 (EDT) Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1hxJL3-0007dc-5h for tarantool-patches@freelists.org; Tue, 13 Aug 2019 02:02:53 +0300 From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 03/13] tuple: relax struct tuple_update dependency on rope Date: Tue, 13 Aug 2019 01:05:13 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Rope will not be used by tuple_update directly in next patches. --- src/box/tuple_update.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/box/tuple_update.c b/src/box/tuple_update.c index 7498d558a..21ea876c9 100644 --- a/src/box/tuple_update.c +++ b/src/box/tuple_update.c @@ -820,31 +820,29 @@ update_field_split(struct region *region, struct update_field *prev, * @retval 0 Success. * @retval -1 Error. */ -int -update_create_rope(struct tuple_update *update, const char *tuple_data, - const char *tuple_data_end, uint32_t field_count) +struct rope * +tuple_rope_new(struct region *region, const char *tuple_data, + const char *tuple_data_end, uint32_t field_count) { - update->rope = rope_new(update->region); - if (update->rope == NULL) - return -1; + struct rope *rope = rope_new(region); + if (rope == NULL) + return NULL; /* Initialize the rope with the old tuple. */ - - struct update_field *first = (struct update_field *) - update_alloc(update->region, sizeof(*first)); + struct update_field *first = + (struct update_field *) update_alloc(region, sizeof(*first)); if (first == NULL) - return -1; + return NULL; const char *field = tuple_data; const char *end = tuple_data_end; if (field == end) - return 0; + return rope; /* Add first field to rope */ mp_next(&tuple_data); uint32_t field_len = tuple_data - field; - update_field_init(first, field, field_len, - end - field - field_len); + update_field_init(first, field, field_len, end - field - field_len); - return rope_append(update->rope, first, field_count); + return rope_append(rope, first, field_count) != 0 ? NULL : rope; } static uint32_t @@ -1119,7 +1117,9 @@ static int update_do_ops(struct tuple_update *update, const char *old_data, const char *old_data_end, uint32_t part_count) { - if (update_create_rope(update, old_data, old_data_end, part_count) != 0) + update->rope = tuple_rope_new(update->region, old_data, old_data_end, + part_count); + if (update->rope == NULL) return -1; struct update_op *op = update->ops; struct update_op *ops_end = op + update->op_count; @@ -1140,7 +1140,9 @@ upsert_do_ops(struct tuple_update *update, const char *old_data, const char *old_data_end, uint32_t part_count, bool suppress_error) { - if (update_create_rope(update, old_data, old_data_end, part_count) != 0) + update->rope = tuple_rope_new(update->region, old_data, old_data_end, + part_count); + if (update->rope == NULL) return -1; struct update_op *op = update->ops; struct update_op *ops_end = op + update->op_count; -- 2.20.1 (Apple Git-117)