gnucash maint: Register speed-up for large files.
Christian Stimming
cstim at code.gnucash.org
Fri Jun 22 18:00:21 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/92ea3ba8 (commit)
from https://github.com/Gnucash/gnucash/commit/f144a8de (commit)
commit 92ea3ba8a60bf4eb19d9b6932fb3ed8b582551a5
Author: Christian Stimming <christian at cstimming.de>
Date: Fri Jun 22 22:17:38 2018 +0200
Register speed-up for large files.
The function qof_book_use_split_action_for_num_field gets called quite a
lot in each register display refresh (due to sorting all splits from
Split.x's xaccSplitOrder function), but it always used to use a KVP
lookup, which is rather expensive compared to accessing a gboolean member
variable.
To get rid of this cost, I had to remove the KVP lookup in this
simple-looking function. The pattern is this: A gboolean cache variable is
introduced, along with an isvalid flag. The lookup makes the expensive
KVP lookup once, then caches the value. The GObject property mechanism
offers a callback for when the setter was called, which is used to mark
the cached value as invalid. A parallel setter method (here:
qof_book_set_option) also just marks the cache as invalid. This covers
all setters, and the getters will use the cached value except for their
first invocation.
The NUM_FIELD_SOURCE feature was introduced in 2012 by the very large
commit 7cdd7372 and apparently its costs never were a problem
until the KVP lookup became more costly due to the std::vector
construction and destruction.
Summary of changes:
libgnucash/engine/qofbook.cpp | 63 +++++++++++++++++++++++++++++++++++++------
libgnucash/engine/qofbook.h | 7 +++++
2 files changed, 62 insertions(+), 8 deletions(-)
More information about the gnucash-patches
mailing list