From dc84e4d10c63a7defdca824005182cade2fa163f Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sat, 31 Aug 2024 20:46:05 +0800 Subject: [PATCH] [gnc-pricedb.h] remove unused gnc_pricedb_substitute_commodity --- libgnucash/engine/gnc-pricedb-p.h | 3 -- libgnucash/engine/gnc-pricedb.cpp | 60 ---------------------- libgnucash/engine/test/utest-gnc-pricedb.c | 5 -- 3 files changed, 68 deletions(-) diff --git a/libgnucash/engine/gnc-pricedb-p.h b/libgnucash/engine/gnc-pricedb-p.h index d1cfc343a1c..207a8d22292 100644 --- a/libgnucash/engine/gnc-pricedb-p.h +++ b/libgnucash/engine/gnc-pricedb-p.h @@ -91,9 +91,6 @@ typedef struct gnc_price_lookup_helper_s } GNCPriceLookupHelper; #define gnc_price_set_guid(P,G) qof_instance_set_guid(QOF_INSTANCE(P),(G)) -void gnc_pricedb_substitute_commodity(GNCPriceDB *db, - gnc_commodity *old_c, - gnc_commodity *new_c); /** register the pricedb object with the gncObject system */ gboolean gnc_pricedb_register (void); diff --git a/libgnucash/engine/gnc-pricedb.cpp b/libgnucash/engine/gnc-pricedb.cpp index fbb4accc325..ae42a8409b5 100644 --- a/libgnucash/engine/gnc-pricedb.cpp +++ b/libgnucash/engine/gnc-pricedb.cpp @@ -2744,66 +2744,6 @@ gnc_pricedb_foreach_price(GNCPriceDB *db, return unstable_price_traversal(db, f, user_data); } -/* ==================================================================== */ -/* commodity substitution */ - -typedef struct -{ - gnc_commodity *old_c; - gnc_commodity *new_c; -} GNCPriceFixupData; - -static gboolean -add_price_to_list (GNCPrice *p, gpointer data) -{ - auto list = static_cast(data); - - *list = g_list_prepend (*list, p); - - return TRUE; -} - -static void -gnc_price_fixup_legacy_commods(gpointer data, gpointer user_data) -{ - auto p = static_cast(data); - auto fixup_data = static_cast(user_data); - gnc_commodity *price_c; - - if (!p) return; - - price_c = gnc_price_get_commodity(p); - if (gnc_commodity_equiv(price_c, fixup_data->old_c)) - { - gnc_price_set_commodity (p, fixup_data->new_c); - } - price_c = gnc_price_get_currency(p); - if (gnc_commodity_equiv(price_c, fixup_data->old_c)) - { - gnc_price_set_currency (p, fixup_data->new_c); - } -} - -void -gnc_pricedb_substitute_commodity(GNCPriceDB *db, - gnc_commodity *old_c, - gnc_commodity *new_c) -{ - GNCPriceFixupData data; - GList *prices = nullptr; - - if (!db || !old_c || !new_c) return; - - data.old_c = old_c; - data.new_c = new_c; - - gnc_pricedb_foreach_price (db, add_price_to_list, &prices, FALSE); - - g_list_foreach (prices, gnc_price_fixup_legacy_commods, &data); - - g_list_free (prices); -} - /***************************************************************************/ /* Semi-lame debugging code */ diff --git a/libgnucash/engine/test/utest-gnc-pricedb.c b/libgnucash/engine/test/utest-gnc-pricedb.c index 25cbc67a617..35577406e9d 100644 --- a/libgnucash/engine/test/utest-gnc-pricedb.c +++ b/libgnucash/engine/test/utest-gnc-pricedb.c @@ -1587,11 +1587,6 @@ gnc_price_fixup_legacy_commods(gpointer data, gpointer user_data)// Local: 0:1:0 test_gnc_price_fixup_legacy_commods (Fixture *fixture, gconstpointer pData) { }*/ -// Not Used -/* gnc_pricedb_substitute_commodity -void -gnc_pricedb_substitute_commodity(GNCPriceDB *db,// Local: 0:0:0 -*/ /* gnc_price_print void gnc_price_print(GNCPrice *p, FILE *f, int indent)// Local: 1:0:0