From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@freelists.org Cc: vdavydov.dev@gmail.com Subject: [PATCH 3/5] tuple: relax struct tuple_update dependency on rope Date: Sun, 14 Jul 2019 00:11:06 +0200 [thread overview] Message-ID: <06b89cfcb8250c6525b3b947d2ac5d972a404016.1563054879.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1563054879.git.v.shpilevoy@tarantool.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)
next prev parent reply other threads:[~2019-07-13 22:11 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-13 22:11 [PATCH 0/5] JSON update preparation Vladislav Shpilevoy 2019-07-13 22:11 ` [PATCH 1/5] tuple: remove alloc and alloc_ctx args from update() Vladislav Shpilevoy 2019-07-13 22:11 ` [PATCH 2/5] rope: make rope library macro template Vladislav Shpilevoy 2019-07-13 22:11 ` Vladislav Shpilevoy [this message] 2019-07-13 22:11 ` [PATCH 4/5] int96: add a missing header Vladislav Shpilevoy 2019-07-13 22:11 ` [PATCH 5/5] tuple: implement update by field name Vladislav Shpilevoy 2019-07-31 12:15 ` [PATCH 0/5] JSON update preparation Vladimir Davydov 2019-07-31 20:36 ` [tarantool-patches] " Vladislav Shpilevoy 2019-08-22 21:18 ` Vladislav Shpilevoy 2019-08-27 22:08 ` [tarantool-patches] " Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=06b89cfcb8250c6525b3b947d2ac5d972a404016.1563054879.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH 3/5] tuple: relax struct tuple_update dependency on rope' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox