fix a re-entrance problem
initially, even the diff applicator was meant to be a "throwaway" object. But then, on writing some tests, it seemed natural to allow re-using a single applicator, after having attached it to some target. With that change, I failed to care for the garbage left back in the "old" sequence after applying one diff; since in the typical usage sequence, the first use builds content from scratch, this problem starts to show up only with the third usage, where the garbage left from the input of the second usage appears at the begin of the "new sequence" Solution is to throw away that garbage explicitly on re-entrance
This commit is contained in:
parent
15246ef323
commit
57b105bbc5
3 changed files with 9 additions and 31 deletions
|
|
@ -212,7 +212,7 @@ namespace diff{
|
|||
empty() const
|
||||
{
|
||||
return attribs_.empty()
|
||||
&& children_.empty();
|
||||
and children_.empty();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,11 @@ namespace diff{
|
|||
{
|
||||
target.swapContent (content);
|
||||
content.resetPos();
|
||||
if (not target.empty()) // re-entrance:
|
||||
{ // discard garbage from previous usage.
|
||||
Rec pristineSequence; // must start new sequence from scratch
|
||||
target.swap (pristineSequence);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -377,7 +382,7 @@ namespace diff{
|
|||
}
|
||||
}
|
||||
|
||||
/** assignement of changed value in one step */
|
||||
/** assignment of changed value in one step */
|
||||
virtual void
|
||||
set (GenNode const& n) override
|
||||
{
|
||||
|
|
|
|||
|
|
@ -144,39 +144,12 @@ namespace test{
|
|||
, ins(CHILD_A)
|
||||
, emu(ATTRIB_NODE)
|
||||
});
|
||||
} // ==> ATTRIB3, ATTRIB1, ATTRIB2, ATTRIB3 := π,
|
||||
} // ==> ATTRIB3 := π, ATTRIB1, ATTRIB2, ATTRIB3,
|
||||
// ATTRIB_NODE{ type ζ, CHILD_A, CHILD_A, CHILD_A }
|
||||
// SUB_NODE{ type ξ, ATTRIB2, CHILD_B, CHILD_A },
|
||||
// CHILD_B, CHILD_T,
|
||||
// ATTRIB_NODE{ type ζ, CHILD_A, CHILD_A, CHILD_A }
|
||||
|
||||
|
||||
/////// TODO : actually found the following content....
|
||||
/*
|
||||
Rec(|
|
||||
α = DataCap|«int»|1,
|
||||
γ = DataCap|«double»|3.1415927,
|
||||
γ = DataCap|«double»|3.45,
|
||||
γ = DataCap|«double»|3.45,
|
||||
α = DataCap|«int»|1,
|
||||
β = DataCap|«long»|2,
|
||||
γ = DataCap|«double»|3.45,
|
||||
δ = DataCap|«Record<GenNode>»|
|
||||
Rec(ζ|{GenNode-ID("_CHILD_string.002")-DataCap|«string»|a,
|
||||
GenNode-ID("_CHILD_string.002")-DataCap|«string»|a,
|
||||
GenNode-ID("_CHILD_string.002")-DataCap|«string»|a})
|
||||
|
|
||||
{GenNode-ID("_CHILD_char.002")-DataCap|«char»|b,
|
||||
GenNode-ID("_CHILD_char.002")-DataCap|«char»|b,
|
||||
GenNode-ID("_CHILD_Time.002")-DataCap|«Time»|78:56:34.012,
|
||||
GenNode-ID("_CHILD_Record.002")-DataCap|«Record<GenNode>»|
|
||||
Rec(ξ| β = DataCap|«long»|2
|
||||
|{GenNode-ID("_CHILD_char.002")-DataCap|«char»|b,
|
||||
GenNode-ID("_CHILD_string.002")-DataCap|«string»|a}),
|
||||
GenNode-ID("_CHILD_char.002")-DataCap|«char»|b,
|
||||
GenNode-ID("_CHILD_Time.002")-DataCap|«Time»|78:56:34.012})
|
||||
|
||||
*/
|
||||
////// TODO : obviously we missed the re-entrance case (which starts to show up at third re-use of the same diff applicator)
|
||||
|
||||
|
||||
virtual void
|
||||
|
|
|
|||
Loading…
Reference in a new issue