-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gnucash/*.cpp] use c++ algorithms with commodities
- Loading branch information
1 parent
778bdac
commit f5601c9
Showing
2 changed files
with
16 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
@author Copyright (C) 2002 Benoit Grégoire <[email protected]> | ||
*/ | ||
#include <config.h> | ||
#include <algorithm> | ||
|
||
#include <gtk/gtk.h> | ||
#include <glib/gi18n.h> | ||
|
@@ -70,18 +71,16 @@ gnc_commodity * gnc_import_select_commodity(const char * cusip, | |
{ | ||
auto ns = ns_str.c_str(); | ||
DEBUG("Looking at namespace %s", ns); | ||
for (auto com : gnc_commodity_table_get_commodities (commodity_table, ns)) | ||
auto commodities{gnc_commodity_table_get_commodities (commodity_table, ns)}; | ||
auto it = std::find_if (commodities.begin(), commodities.end(), | ||
[cusip](auto com) | ||
{ return !g_strcmp0 (gnc_commodity_get_cusip (com), cusip); }); | ||
if (it != commodities.end()) | ||
{ | ||
DEBUG("Looking at commodity %s", gnc_commodity_get_fullname (com)); | ||
if (!g_strcmp0 (gnc_commodity_get_cusip (com), cusip)) | ||
{ | ||
retval = com; | ||
DEBUG("Commodity %s matches.", gnc_commodity_get_fullname (com)); | ||
break; | ||
} | ||
} | ||
if (retval) | ||
retval = *it; | ||
DEBUG("Commodity %s matches.", gnc_commodity_get_fullname (*it)); | ||
break; | ||
}; | ||
} | ||
|
||
if (retval == NULL && ask_on_unknown != 0) | ||
|