From a98730120487e87b000da65b9ccbbabf089933ee Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Thu, 3 Dec 2020 09:32:25 +0300 Subject: [PATCH] mdbx++: refine abort/commit. More for https://github.com/erthink/libmdbx/pull/143 Change-Id: I07de4c43d039f904495f0f4caf586d8764174dcf --- .github/actions/spelling/expect.txt | 2 ++ src/mdbx.c++ | 16 ++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 75cdff13..20846e42 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -137,6 +137,7 @@ calloc cas casename cassert +castis castortech cattr cbegin @@ -1390,6 +1391,7 @@ rw samedata samelength SAMSUNG +sasgas savailable scalability sched diff --git a/src/mdbx.c++ b/src/mdbx.c++ index 759d4ff8..73a222f3 100644 --- a/src/mdbx.c++ +++ b/src/mdbx.c++ @@ -1314,22 +1314,18 @@ txn_managed::~txn_managed() noexcept { void txn_managed::abort() { const error err = static_cast(::mdbx_txn_abort(handle_)); - if (MDBX_UNLIKELY(err.code() != MDBX_SUCCESS)) { - if (err.code() != MDBX_THREAD_MISMATCH) - handle_ = nullptr; + if (MDBX_LIKELY(err.code() != MDBX_THREAD_MISMATCH)) + handle_ = nullptr; + if (MDBX_UNLIKELY(err.code() != MDBX_SUCCESS)) err.throw_exception(); - } - handle_ = nullptr; } void txn_managed::commit() { const error err = static_cast(::mdbx_txn_commit(handle_)); - if (MDBX_UNLIKELY(err.code() != MDBX_SUCCESS)) { - if (err.code() != MDBX_THREAD_MISMATCH) - handle_ = nullptr; + if (MDBX_LIKELY(err.code() != MDBX_THREAD_MISMATCH)) + handle_ = nullptr; + if (MDBX_UNLIKELY(err.code() != MDBX_SUCCESS)) err.throw_exception(); - } - handle_ = nullptr; } //------------------------------------------------------------------------------