[gnc-plugin-page-account-tree.cpp] use c++ algo

This commit is contained in:
Christopher Lam 2024-06-18 08:26:30 +08:00
parent 6790430ee8
commit 2902f1de0f

View File

@ -34,6 +34,8 @@
#include <config.h>
#include <algorithm>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#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<delete_helper_t*>(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);
}