From 4086eda5611774a474f6dbf5dc4a5fa9e23cf48c Mon Sep 17 00:00:00 2001 From: David Hampton Date: Wed, 8 Mar 2006 00:06:35 +0000 Subject: [PATCH] Use the pointer to the commodity as a hash key instead of looking up the commodity string and then hashing that. Fixes 332678. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13528 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 6 ++++++ src/engine/gnc-pricedb.c | 26 ++------------------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 725232a56b..40104bf103 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-03-07 David Hampton + + * src/engine/gnc-pricedb.c: Use the pointer to the commodity as a + hash key instead of looking up the commodity string and then + hashing that. Fixes 332678. + 2006-03-08 Andreas Köhler * configure.in: diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c index e6d7f45978..94da203405 100644 --- a/src/engine/gnc-pricedb.c +++ b/src/engine/gnc-pricedb.c @@ -561,30 +561,8 @@ gnc_price_list_equal(GList *prices1, GList *prices2) description of GNCPrice lists). The top-level key is the commodity you want the prices for, and the second level key is the commodity that the value is expressed in terms of. - */ -static guint -commodity_hash (gconstpointer key) -{ - gnc_commodity * com = (gnc_commodity *) key; - - g_return_val_if_fail (key, 0); - - return g_str_hash (gnc_commodity_get_unique_name (com)); -} - -static gint -commodity_equal (gconstpointer a, gconstpointer b) -{ - gnc_commodity * ca = (gnc_commodity *) a; - gnc_commodity * cb = (gnc_commodity *) b; - - g_return_val_if_fail (a && b, FALSE); - - return gnc_commodity_equiv (ca, cb); -} - static GNCPriceDB * gnc_pricedb_create(QofBook * book) { @@ -612,7 +590,7 @@ gnc_pricedb_create(QofBook * book) provide one here. */ qof_collection_set_data (col, result); - result->commodity_hash = g_hash_table_new(commodity_hash, commodity_equal); + result->commodity_hash = g_hash_table_new(NULL, NULL); g_return_val_if_fail (result->commodity_hash, NULL); return result; } @@ -832,7 +810,7 @@ add_price(GNCPriceDB *db, GNCPrice *p) currency_hash = g_hash_table_lookup(db->commodity_hash, commodity); if(!currency_hash) { - currency_hash = g_hash_table_new(commodity_hash, commodity_equal); + currency_hash = g_hash_table_new(NULL, NULL); g_hash_table_insert(db->commodity_hash, commodity, currency_hash); }