indicate how RecordContentMutator will be used
This commit is contained in:
parent
5cbdcc0f22
commit
aa46940daa
3 changed files with 17 additions and 14 deletions
|
|
@ -106,6 +106,15 @@ namespace diff{
|
|||
{
|
||||
pos = attribs.begin();
|
||||
}
|
||||
|
||||
void
|
||||
preAllocateStorage(size_t attribCnt, size_t childrenCnt)
|
||||
{
|
||||
// heuristics for storage pre-allocation (for tree diff application)
|
||||
attribs.reserve (attribCnt * 120 / 100);
|
||||
children.reserve (childrenCnt * 120 / 100);
|
||||
ASSERT (this->empty());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -453,13 +453,14 @@ namespace diff{
|
|||
return *this;
|
||||
}
|
||||
|
||||
/* === low-level access (e.g. for diff application === */
|
||||
/* === low-level access (for diff application === */
|
||||
|
||||
Storage& attribs() { return record_.attribs_; }
|
||||
Storage& children() { return record_.children_; }
|
||||
void
|
||||
swapContent (ContentMutator& alteredContent)
|
||||
{
|
||||
if (alteredContent.empty())
|
||||
alteredContent.preAllocateStorage(record_.attribs_.size(),
|
||||
record_.children_.size());
|
||||
std::swap (record_.attribs_, alteredContent.attribs);
|
||||
std::swap (record_.children_, alteredContent.children);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,11 +84,10 @@ namespace diff{
|
|||
class DiffApplicationStrategy<Rec::Mutator>
|
||||
: public TreeDiffInterpreter
|
||||
{
|
||||
using Storage = RecordSetup<GenNode>::Storage;
|
||||
using Content = Rec::ContentMutator;
|
||||
|
||||
Rec::Mutator& target_;
|
||||
Storage attribs_;
|
||||
Storage children_;
|
||||
Content content_;
|
||||
|
||||
|
||||
/* == Implementation of the list diff application primitives == */
|
||||
|
|
@ -150,15 +149,9 @@ namespace diff{
|
|||
explicit
|
||||
DiffApplicationStrategy(Rec::Mutator& mutableTargetRecord)
|
||||
: target_(mutableTargetRecord)
|
||||
, attribs_()
|
||||
, children_()
|
||||
, content_()
|
||||
{
|
||||
swap (attribs_, target_.attribs());
|
||||
swap (children_, target_.children());
|
||||
|
||||
// heuristics for storage pre-allocation
|
||||
target_.attribs().reserve (attribs_.size() * 120 / 100);
|
||||
target_.children().reserve (children_.size() * 120 / 100);
|
||||
target_.swapContent (content_);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue