gnucash maint: Simplify gnc_commodity equality and compare functions.
John Ralls
jralls at code.gnucash.org
Tue Jan 24 13:47:14 EST 2023
Updated via https://github.com/Gnucash/gnucash/commit/46f9fb01 (commit)
from https://github.com/Gnucash/gnucash/commit/a81b72f0 (commit)
commit 46f9fb01c972615ff77152f0c76489d761925e15
Author: John Ralls <jralls at ceridwen.us>
Date: Tue Jan 24 09:46:48 2023 -0800
Simplify gnc_commodity equality and compare functions.
gnc_commodity_compare is used for sorting and so needs to have a less-than
return value. The only place it's used presents nothing to the UI; a GncGUID
ordering is fast and stable.
GnuCash allows only one commodity per book for any namespace/mnemonic pair, so
the exhaustive string comparisons are superflous. While the current engine
design allows only one instance of any object, meaning that a pointer comparison
is sufficient to determine equality, that may not be true in the future, but the
GncGUID is guaranteed to sufficiently identify a single commodity. Note that
gnc_commodity_equiv is used to enforce that single-commodity rule and so cannot
use GncGUID comparison.
Summary of changes:
libgnucash/engine/gnc-commodity.c | 71 +++++++--------------------------------
1 file changed, 12 insertions(+), 59 deletions(-)
More information about the gnucash-patches
mailing list