From 1a2f6445701549dcfe61325b298b91138d799da0 Mon Sep 17 00:00:00 2001 From: Murch Date: Mon, 21 Aug 2023 15:27:23 -0400 Subject: [PATCH] Refactor ComputeAndSetWaste() --- src/wallet/coinselection.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp index 609725f7c4a60c..98543396f1deca 100644 --- a/src/wallet/coinselection.cpp +++ b/src/wallet/coinselection.cpp @@ -500,13 +500,8 @@ void SelectionResult::SetBumpFeeDiscount(const CAmount discount) void SelectionResult::ComputeAndSetWaste(const CAmount min_viable_change, const CAmount change_cost, const CAmount change_fee) { - const CAmount change = GetChange(min_viable_change, change_fee); - - if (change > 0) { - m_waste = GetSelectionWaste(change_cost, m_target, m_use_effective); - } else { - m_waste = GetSelectionWaste(0, m_target, m_use_effective); - } + bool makes_change = (0 != GetChange(min_viable_change, change_fee)); + m_waste = GetSelectionWaste(makes_change ? change_cost : 0, m_target, m_use_effective); } CAmount SelectionResult::GetWaste() const