From 2365ba7b97a00d4c14fb0d1df1298b50ad4c9466 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Wed, 9 Oct 2019 12:06:03 -0600 Subject: [PATCH] Put size increment and decrement on their own lines --- src/mempoollimit.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mempoollimit.cpp b/src/mempoollimit.cpp index 4e02f8987..08430f1b5 100644 --- a/src/mempoollimit.cpp +++ b/src/mempoollimit.cpp @@ -86,7 +86,8 @@ void WeightedTxTree::add(const WeightedTxInfo& weightedTxInfo) txIdAndWeights.push_back(weightedTxInfo); childWeights.push_back(ZERO_WEIGHT); txIdToIndexMap[weightedTxInfo.txId] = size; - backPropagate(size++, weightedTxInfo.txWeight); + backPropagate(size, weightedTxInfo.txWeight); + size += 1; } void WeightedTxTree::remove(const uint256& txId) @@ -97,7 +98,11 @@ void WeightedTxTree::remove(const uint256& txId) size_t removeIndex = txIdToIndexMap[txId]; - TxWeight lastChildWeight = txIdAndWeights[--size].txWeight; + // We reduce the size at the start of this method to avoid saying size - 1 + // when refering to the last element of the array below + size -= 1; + + TxWeight lastChildWeight = txIdAndWeights[size].txWeight; backPropagate(size, lastChildWeight.negate()); if (removeIndex < size) {