mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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
This commit is contained in:
parent
e278c02ea0
commit
4086eda561
@ -1,3 +1,9 @@
|
||||
2006-03-07 David Hampton <hampton@employees.org>
|
||||
|
||||
* 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 <andi5.py@gmx.net>
|
||||
|
||||
* configure.in:
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user