From c2d44b89fbd025df564d4fec6958f8ddb5a1fd16 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 31 May 2015 17:59:52 -0700 Subject: [PATCH] Replace Scrub2 direct KVP access with Split lot-guid accessors. --- src/engine/Scrub2.c | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/src/engine/Scrub2.c b/src/engine/Scrub2.c index 5532785c4e..757589d316 100644 --- a/src/engine/Scrub2.c +++ b/src/engine/Scrub2.c @@ -242,17 +242,13 @@ xaccLotScrubDoubleBalance (GNCLot *lot) static inline gboolean is_subsplit (Split *split) { - KvpValue *kval; /* generic stop-progress conditions */ if (!split) return FALSE; g_return_val_if_fail (split->parent, FALSE); /* If there are no sub-splits, then there's nothing to do. */ - kval = kvp_frame_get_slot (split->inst.kvp_data, "lot-split"); - if (!kval) return FALSE; - - return TRUE; + return xaccSplitHasPeers (split); } /* ================================================================= */ @@ -267,30 +263,9 @@ is_subsplit (Split *split) static void remove_guids (Split *sa, Split *sb) { - KvpFrame *ksub; - - /* Find and remove the matching guid's */ - ksub = (KvpFrame*)gnc_kvp_bag_find_by_guid (sa->inst.kvp_data, "lot-split", - "peer_guid", qof_instance_get_guid(sb)); - if (ksub) - { - gnc_kvp_bag_remove_frame (sa->inst.kvp_data, "lot-split", ksub); - kvp_frame_delete (ksub); - } - - /* Now do it in the other direction */ - ksub = (KvpFrame*)gnc_kvp_bag_find_by_guid (sb->inst.kvp_data, "lot-split", - "peer_guid", qof_instance_get_guid(sa)); - if (ksub) - { - gnc_kvp_bag_remove_frame (sb->inst.kvp_data, "lot-split", ksub); - kvp_frame_delete (ksub); - } - - /* Finally, merge b's lot-splits, if any, into a's */ - /* This is an important step, if it got busted into many pieces. */ - gnc_kvp_bag_merge (sa->inst.kvp_data, "lot-split", - sb->inst.kvp_data, "lot-split"); + xaccSplitRemovePeerSplit (sa, sb); + xaccSplitRemovePeerSplit (sb, sa); + xaccSplitMergePeerSplits (sa, sb); } /* The merge_splits() routine causes the amount & value of sb @@ -350,7 +325,6 @@ xaccScrubMergeSubSplits (Split *split, gboolean strict) Transaction *txn; SplitList *node; GNCLot *lot; - const GncGUID *guid; if (strict && (FALSE == is_subsplit (split))) return FALSE; @@ -376,9 +350,7 @@ restart: * example. Only worry about adjacent sub-splits. By * repeatedly merging adjacent subsplits, we'll get the non- * adjacent ones too. */ - guid = qof_instance_get_guid(s); - if (gnc_kvp_bag_find_by_guid (split->inst.kvp_data, "lot-split", - "peer_guid", guid) == NULL) + if (!xaccSplitIsPeerSplit (split, s)) continue; }