From eb829e69940d498b5c8e06cc68433ffe89162139 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 1 Nov 2015 04:49:22 +0100 Subject: [PATCH] Bugfix: yet another init problem after swapping contents yeah, working with open fire is dangerous... For performace reasons I've undercut the premise to make GenNode / Record immutable. Now I'm dealing with raw storage layout together with this quite hairy distinction between "attribute scope" and "child scope" In hindsight, it might have been better to implement Record as a single list, and to maintain a shortcut pointer to jump to the start of the attributes. --- src/lib/diff/record-content-mutator.hpp | 14 +++++++++++++- src/lib/diff/tree-diff-application.hpp | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/diff/record-content-mutator.hpp b/src/lib/diff/record-content-mutator.hpp index e0b93d109..892a3253e 100644 --- a/src/lib/diff/record-content-mutator.hpp +++ b/src/lib/diff/record-content-mutator.hpp @@ -30,7 +30,10 @@ ** details of doing so are highly coupled to the actual storage implementation ** of #Record, as well as to the actual procedure to apply a diff message, as ** implemented in lib::diff::DiffApplicationStrategy. - ** + ** @warning this struct is marked "internal" for a reason; + ** it serves the purpose to remove technicalities from usage site, + ** yet it is \em not a proper abstraction. Be sure you understand + ** the storage layout, especially when testing for iteration end. ** @see generic-record-update-test.cpp ** @see tree-diff-application-test.cpp ** @see Record::Mutator @@ -115,6 +118,15 @@ namespace diff{ void resetPos() + { + if (attribs.empty()) + jumpToChildScope(); + else + jumpToAttribScope(); + } + + void + jumpToAttribScope() { pos = attribs.begin(); } diff --git a/src/lib/diff/tree-diff-application.hpp b/src/lib/diff/tree-diff-application.hpp index 5bc0d8912..119ed506c 100644 --- a/src/lib/diff/tree-diff-application.hpp +++ b/src/lib/diff/tree-diff-application.hpp @@ -108,6 +108,7 @@ namespace diff{ void init() { target.swapContent (content); + content.resetPos(); } };