gnucash master: Multiple changes pushed
Mike Alexander
mta at code.gnucash.org
Sat Nov 7 19:11:00 EST 2015
Updated via https://github.com/Gnucash/gnucash/commit/310be62e (commit)
via https://github.com/Gnucash/gnucash/commit/7fcf6a13 (commit)
from https://github.com/Gnucash/gnucash/commit/fdc9a6a1 (commit)
commit 310be62ed3298adbc327bdc2e10951ab19cc0f08
Author: Mike Alexander <mta at umich.edu>
Date: Fri Nov 6 23:13:41 2015 -0500
Add some better comments.
diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c
index 2cd79b8..6d3c665 100644
--- a/src/engine/gnc-pricedb.c
+++ b/src/engine/gnc-pricedb.c
@@ -1494,8 +1494,11 @@ pricedb_get_prices_internal(GNCPriceDB *db, const gnc_commodity *commodity,
{
if (forward_list)
{
- /* Since we have a currency both lists came directly from a
- currency hash table we know they are both sorted already. */
+ /* Since we have a currency both lists are a direct copy of a price
+ list in the price DB. This means the lists are already sorted
+ from newest to oldest and we can just merge them together. This
+ is substantially faster than concatenating them and sorting the
+ resulting list. */
PriceList *merged_list;
merged_list = pricedb_price_list_merge (forward_list, reverse_list);
g_list_free (forward_list);
@@ -1563,6 +1566,16 @@ typedef struct
gboolean before;
} UsesCommodity;
+/* price_list_scan_any_currency is the helper function used with
+ * gnc_pricedb_foreach_price by the "any_currency" price lookup functions. It
+ * builds a list of prices that are either to or from the commodity "com".
+ * The resulting list will include all prices newer than "t" and the first
+ * price older than "t". All older prices will be ignored. Since in the most
+ * common cases we will be looking for recent prices which are at the front of
+ * the various price lists, this is considerably faster than concatenating all
+ * the relevant price lists and sorting the result.
+*/
+
static gboolean
price_list_scan_any_currency(GNCPrice *price, gpointer data)
{
commit 7fcf6a1301ab0b149a1427ed3d616a715bdb1029
Author: Mike Alexander <mta at umich.edu>
Date: Fri Nov 6 22:43:00 2015 -0500
Make sure commodity-tz-quote-triple->price always returns a value.
Because of misplaced parens it was not returning a value if no price
for the same day was in the price DB.
diff --git a/src/scm/price-quotes.scm b/src/scm/price-quotes.scm
index b161dcf..2ab32e4 100644
--- a/src/scm/price-quotes.scm
+++ b/src/scm/price-quotes.scm
@@ -433,21 +433,21 @@
(gnc-price-set-value saved-price price)
(gnc-price-commit-edit saved-price)
#f)
- #f)
- (let ((gnc-price (gnc-price-create book)))
- (if (not gnc-price)
- (string-append
- currency-str ":" (gnc-commodity-get-mnemonic commodity))
- (begin
- (gnc-price-begin-edit gnc-price)
- (gnc-price-set-commodity gnc-price commodity)
- (gnc-price-set-currency gnc-price currency)
- (gnc-price-set-time gnc-price gnc-time)
- (gnc-price-set-source gnc-price PRICE-SOURCE-FQ)
- (gnc-price-set-typestr gnc-price price-type)
- (gnc-price-set-value gnc-price price)
- (gnc-price-commit-edit gnc-price)
- gnc-price)))))
+ #f))
+ (let ((gnc-price (gnc-price-create book)))
+ (if (not gnc-price)
+ (string-append
+ currency-str ":" (gnc-commodity-get-mnemonic commodity))
+ (begin
+ (gnc-price-begin-edit gnc-price)
+ (gnc-price-set-commodity gnc-price commodity)
+ (gnc-price-set-currency gnc-price currency)
+ (gnc-price-set-time gnc-price gnc-time)
+ (gnc-price-set-source gnc-price PRICE-SOURCE-FQ)
+ (gnc-price-set-typestr gnc-price price-type)
+ (gnc-price-set-value gnc-price price)
+ (gnc-price-commit-edit gnc-price)
+ gnc-price))))
))
))
Summary of changes:
src/engine/gnc-pricedb.c | 17 +++++++++++++++--
src/scm/price-quotes.scm | 30 +++++++++++++++---------------
2 files changed, 30 insertions(+), 17 deletions(-)
More information about the gnucash-changes
mailing list