mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-25 08:41:01 +01:00
[poincare] TreeNode have a zero refcount by default
This commit is contained in:
@@ -36,13 +36,6 @@ public:
|
||||
m_referenceCounter = refCount;
|
||||
}
|
||||
|
||||
void deepResetReferenceCounter() { //TODO make this method private with friends that can access it
|
||||
setReferenceCounter(0);
|
||||
for (TreeNode * t : depthFirstChildren()) {
|
||||
t->setReferenceCounter(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Ghost
|
||||
virtual bool isGhost() const { return false; }
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ void TreeByReference::buildGhostChildren() {
|
||||
renameNode(copy, false);
|
||||
for (TreeNode * child : copy->depthFirstChildren()) {
|
||||
renameNode(child, false);
|
||||
child->retain();
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ TreeByReference TreeByReference::clone() const {
|
||||
return TreeByReference(TreePool::sharedPool()->node(allocationFailureNodeId));
|
||||
}
|
||||
TreeNode * nodeCopy = TreePool::sharedPool()->deepCopy(myNode);
|
||||
nodeCopy->deepResetReferenceCounter();
|
||||
return TreeByReference(nodeCopy);
|
||||
}
|
||||
|
||||
@@ -97,6 +96,7 @@ void TreeByReference::replaceWithAllocationFailureInPlace(int currentNumberOfChi
|
||||
//TODO static assert that the size is smaller
|
||||
TreeNode * newAllocationFailureNode = TreePool::sharedPool()->deepCopy(staticAllocFailNode);
|
||||
newAllocationFailureNode->rename(m_identifier, true);
|
||||
newAllocationFailureNode->retain();
|
||||
if (p.isDefined()) {
|
||||
assert(indexInParentNode >= 0);
|
||||
/* Set the refCount to previousRefCount-1 because the previous parent is
|
||||
|
||||
@@ -30,7 +30,7 @@ void TreeNode::rename(int identifier, bool unregisterPreviousIdentifier) {
|
||||
TreePool::sharedPool()->unregisterNode(this);
|
||||
}
|
||||
m_identifier = identifier;
|
||||
m_referenceCounter = 1;
|
||||
m_referenceCounter = 0;
|
||||
TreePool::sharedPool()->registerNode(this);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ bool TreeNode::hasSibling(const TreeNode * e) const {
|
||||
|
||||
TreeNode::TreeNode() :
|
||||
m_identifier(TreePool::NoNodeIdentifier),
|
||||
m_referenceCounter(1)
|
||||
m_referenceCounter(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user