mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[transaction.cpp] speed up book close
This commit is contained in:
parent
d21d6f9344
commit
fe2cdf42c7
@ -3070,6 +3070,12 @@ destroy_tx_on_book_close(QofInstance *ent, gpointer data)
|
|||||||
xaccTransDestroy(tx);
|
xaccTransDestroy(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
trans_reverse_order (const Transaction* a, const Transaction* b)
|
||||||
|
{
|
||||||
|
return xaccTransOrder (b, a);
|
||||||
|
}
|
||||||
|
|
||||||
/** Handles book end - frees all transactions from the book
|
/** Handles book end - frees all transactions from the book
|
||||||
*
|
*
|
||||||
* @param book Book being closed
|
* @param book Book being closed
|
||||||
@ -3080,7 +3086,12 @@ gnc_transaction_book_end(QofBook* book)
|
|||||||
QofCollection *col;
|
QofCollection *col;
|
||||||
|
|
||||||
col = qof_book_get_collection(book, GNC_ID_TRANS);
|
col = qof_book_get_collection(book, GNC_ID_TRANS);
|
||||||
qof_collection_foreach(col, destroy_tx_on_book_close, nullptr);
|
|
||||||
|
// destroy all transactions from latest to earliest, because
|
||||||
|
// accounts' splits are stored chronologically and removing from
|
||||||
|
// the end is faster than from the middle.
|
||||||
|
qof_collection_foreach_sorted (col, destroy_tx_on_book_close, nullptr,
|
||||||
|
(GCompareFunc)trans_reverse_order);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
Loading…
Reference in New Issue
Block a user