From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 E427F445320 for ; Fri, 10 Jul 2020 23:36:33 +0300 (MSK) References: <20200710075605.217824-1-gorcunov@gmail.com> <20200710075605.217824-5-gorcunov@gmail.com> From: Vladislav Shpilevoy Message-ID: <804b33af-ddea-aefa-b69f-5615831967e7@tarantool.org> Date: Fri, 10 Jul 2020 22:36:32 +0200 MIME-Version: 1.0 In-Reply-To: <20200710075605.217824-5-gorcunov@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [Tarantool-patches] [PATCH 4/5] qsync: txn_commit -- use txn flag instead of caching variable List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov , tml On 10/07/2020 09:56, Cyrill Gorcunov wrote: > All over the code (including txn_libmo) we use txn_has_flag > helper, lets do the same here. There is no need for a separate > variable. It simply confuses (note though that sometimes such > trick is used to fetch current value of some variable which > might be changed externally but this is not out case we rely > on single thread here). > > I also added a few empty lines to separate logical code blocks > for better readability. > > Signed-off-by: Cyrill Gorcunov > --- > src/box/txn.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/src/box/txn.c b/src/box/txn.c > index 613eb7aef..feb9a10c6 100644 > --- a/src/box/txn.c > +++ b/src/box/txn.c > @@ -811,8 +811,7 @@ txn_commit(struct txn *txn) > return -1; > } > > - bool is_sync = txn_has_flag(txn, TXN_WAIT_SYNC); > - if (is_sync) { > + if (txn_has_flag(txn, TXN_WAIT_SYNC)) { Здесь это сохранено в переменную не просто так. А как раз за тем, чтобы не вычитывать флаг заново на каждый иф. Не надо это менять плиз. > /* > * Remote rows, if any, come before local rows, so > * check for originating instance id here. > @@ -834,7 +833,7 @@ txn_commit(struct txn *txn) > > fiber_set_txn(fiber(), NULL); > if (journal_write(req) != 0) { > - if (is_sync) > + if (txn_has_flag(txn, TXN_WAIT_SYNC)) > txn_limbo_abort(&txn_limbo, limbo_entry); > fiber_set_txn(fiber(), txn); > txn_rollback(txn); > @@ -844,7 +843,8 @@ txn_commit(struct txn *txn) > diag_log(); > return -1; > } > - if (is_sync) { > + > + if (txn_has_flag(txn, TXN_WAIT_SYNC)) { > if (txn_has_flag(txn, TXN_WAIT_ACK)) { > int64_t lsn = req->rows[req->n_rows - 1]->lsn; > txn_limbo_assign_local_lsn(&txn_limbo, limbo_entry, > @@ -857,6 +857,7 @@ txn_commit(struct txn *txn) > return -1; > } > } > + > if (!txn_has_flag(txn, TXN_IS_DONE)) { > txn->signature = req->res; > txn_complete(txn); >