From 2902f1de0f25135b9e6e0d8091ea3142ac4b951e Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 18 Jun 2024 08:26:30 +0800 Subject: [PATCH] [gnc-plugin-page-account-tree.cpp] use c++ algo --- .../gnome/gnc-plugin-page-account-tree.cpp | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.cpp b/gnucash/gnome/gnc-plugin-page-account-tree.cpp index 2db6f0bc8a..b92631b129 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.cpp +++ b/gnucash/gnome/gnc-plugin-page-account-tree.cpp @@ -34,6 +34,8 @@ #include +#include + #include #include #include "gnc-plugin-page-account-tree.h" @@ -1149,21 +1151,11 @@ static gpointer delete_account_helper (Account * account, gpointer data) { auto helper_res = static_cast(data); - auto splits{xaccAccountGetSplits (account)}; + auto& splits{xaccAccountGetSplits (account)}; + auto split_ro = [](auto s) -> bool { return xaccTransGetReadOnly (xaccSplitGetParent (s)); }; - if (!splits.empty()) - { - helper_res->has_splits = TRUE; - for (auto s : splits) - { - Transaction *txn = xaccSplitGetParent (s); - if (xaccTransGetReadOnly (txn)) - { - helper_res->has_ro_splits = TRUE; - break; - } - } - } + helper_res->has_splits = !splits.empty(); + helper_res->has_ro_splits = std::any_of (splits.begin(), splits.end(), split_ro); return GINT_TO_POINTER (helper_res->has_splits || helper_res->has_ro_splits); }