diff --git a/poincare/include/poincare/tree_by_reference.h b/poincare/include/poincare/tree_by_reference.h index 34d381ea6..c1635a753 100644 --- a/poincare/include/poincare/tree_by_reference.h +++ b/poincare/include/poincare/tree_by_reference.h @@ -56,9 +56,6 @@ public: bool isGhost() const { return node()->isGhost(); } bool isUninitialized() const { return m_identifier == TreeNode::NoNodeIdentifier; } -#if POINCARE_ALLOW_STATIC_NODES - bool isStatic() const { return node()->isStatic(); } -#endif /* Hierarchy */ bool hasChild(TreeByReference t) const; diff --git a/poincare/include/poincare/tree_node.h b/poincare/include/poincare/tree_node.h index 90a787d13..c5235eae2 100644 --- a/poincare/include/poincare/tree_node.h +++ b/poincare/include/poincare/tree_node.h @@ -22,16 +22,10 @@ class TreeNode { friend class TreePool; public: static constexpr int NoNodeIdentifier = -1; -#if POINCARE_ALLOW_STATIC_NODES - static constexpr int FirstStaticNodeIdentifier = -2; -#endif virtual ~TreeNode() {} // Attributes -#if POINCARE_ALLOW_STATIC_NODES - bool isStatic() const { return m_identifier <= FirstStaticNodeIdentifier; } -#endif void setParentIdentifier(int parentID) { m_parentIdentifier = parentID; } void deleteParentIdentifier() { m_parentIdentifier = NoNodeIdentifier; } virtual size_t size() const = 0; diff --git a/poincare/include/poincare/tree_pool.h b/poincare/include/poincare/tree_pool.h index 868628b3e..80f875403 100644 --- a/poincare/include/poincare/tree_pool.h +++ b/poincare/include/poincare/tree_pool.h @@ -11,8 +11,6 @@ #include #endif -#define POINCARE_ALLOW_STATIC_NODES 0 - namespace Poincare { class TreeByReference; @@ -29,13 +27,6 @@ public: // Node TreeNode * node(int identifier) const { -#if POINCARE_ALLOW_STATIC_NODES - if (identifier <= TreeNode::FirstStaticNodeIdentifier) { - int index = indexOfStaticNode(identifier); - assert(index >= 0 && index < MaxNumberOfStaticNodes); - return m_staticNodes[index]; - } -#endif assert(identifier >= 0 && identifier <= MaxNumberOfNodes); return m_nodeForIdentifier[identifier]; } @@ -50,11 +41,6 @@ public: TreeNode * deepCopy(TreeNode * node); TreeNode * copyTreeFromAddress(const void * address, size_t size); -#if POINCARE_ALLOW_STATIC_NODES - void registerStaticNodeIfRequired(TreeNode * node); - void registerStaticNode(TreeNode * node); -#endif - #if POINCARE_TREE_LOG void flatLog(std::ostream & stream); void treeLog(std::ostream & stream); @@ -65,9 +51,6 @@ public: private: constexpr static int BufferSize = 32768; constexpr static int MaxNumberOfNodes = BufferSize/sizeof(TreeNode); -#if POINCARE_ALLOW_STATIC_NODES - constexpr static int MaxNumberOfStaticNodes = 200; // TODO: count how may are needed -#endif static TreePool * SharedStaticPool; // TreeNode @@ -82,11 +65,6 @@ private: node->rename(generateIdentifier(), unregisterPreviousIdentifier); } -#if POINCARE_ALLOW_STATIC_NODES - int identifierOfStaticNodeAtIndex(int index) const { return TreeNode::FirstStaticNodeIdentifier-index;} // We do not want positive indexes that are reserved for pool nodes, and -1 is reserved for node initialisation. - int indexOfStaticNode(int id) const { return -(id - TreeNode::FirstStaticNodeIdentifier);} -#endif - // Iterators TreeNode * first() const { return reinterpret_cast(const_cast(m_buffer)); } TreeNode * last() const { return reinterpret_cast(const_cast(m_cursor)); } @@ -167,9 +145,6 @@ private: char m_buffer[BufferSize]; IdentifierStack m_identifiers; TreeNode * m_nodeForIdentifier[MaxNumberOfNodes]; -#if POINCARE_ALLOW_STATIC_NODES - TreeNode * m_staticNodes[MaxNumberOfStaticNodes]; -#endif }; } diff --git a/poincare/src/tree_by_reference.cpp b/poincare/src/tree_by_reference.cpp index 67a46b583..26450654c 100644 --- a/poincare/src/tree_by_reference.cpp +++ b/poincare/src/tree_by_reference.cpp @@ -9,12 +9,6 @@ namespace Poincare { /* Clone */ TreeByReference TreeByReference::clone() const { -#if POINCARE_ALLOW_STATIC_NODES - if (isStatic()) { - // Static nodes are not copied - return TreeByReference(node()); - } -#endif /* TODO Remove ? if (isUninitialized()) { return TreeByReference(); @@ -56,15 +50,6 @@ void TreeByReference::replaceChildInPlace(TreeByReference oldChild, TreeByRefere assert(!isUninitialized()); -#if POINCARE_ALLOW_STATIC_NODES - // If the new node is static, copy it in the pool and add the copy - if (newChild.isStatic()) { - TreeByReference newT = TreeByReference(TreePool::sharedPool()->deepCopy(newChild.node())); - replaceChildInPlace(oldChild, newT); - return; - } -#endif - // If the new child has a parent, detach from it newChild.detachFromParent(); @@ -117,9 +102,6 @@ void TreeByReference::mergeChildrenAtIndexInPlace(TreeByReference t, int i) { } void TreeByReference::swapChildrenInPlace(int i, int j) { -#if POINCARE_ALLOW_STATIC_NODES - assert(!isStatic()); -#endif assert(i >= 0 && i < numberOfChildren()); assert(j >= 0 && j < numberOfChildren()); if (i == j) { @@ -148,14 +130,6 @@ void TreeByReference::addChildAtIndexInPlace(TreeByReference t, int index, int c assert(!t.isUninitialized()); assert(index >= 0 && index <= currentNumberOfChildren); -#if POINCARE_ALLOW_STATIC_NODES - // If the new node is static, copy it in the pool and add the copy - if (t.isStatic()) { - TreeByReference newT = TreeByReference(TreePool::sharedPool()->deepCopy(t.node())); - addChildAtIndexInPlace(newT, index, currentNumberOfChildren); - return; - } -#endif // If t has a parent, detach t from it. t.detachFromParent(); assert(t.parent().isUninitialized()); diff --git a/poincare/src/tree_node.cpp b/poincare/src/tree_node.cpp index b257e32f1..2a417b760 100644 --- a/poincare/src/tree_node.cpp +++ b/poincare/src/tree_node.cpp @@ -8,12 +8,6 @@ namespace Poincare { // Node operations void TreeNode::release(int currentNumberOfChildren) { -#if POINCARE_ALLOW_STATIC_NODES - if (isStatic()) { - // Do not release static nodes - return; - } -#endif m_referenceCounter--; if (m_referenceCounter == 0) { deleteParentIdentifierInChildren(); diff --git a/poincare/src/tree_pool.cpp b/poincare/src/tree_pool.cpp index 80b1225b2..a6fdc9136 100644 --- a/poincare/src/tree_pool.cpp +++ b/poincare/src/tree_pool.cpp @@ -33,33 +33,6 @@ void TreePool::freeIdentifier(int identifier) { } } -#if POINCARE_ALLOW_STATIC_NODES -void TreePool::registerStaticNodeIfRequired(TreeNode * node) { - if (node->identifier() == -1) { - registerStaticNode(node); - } -} - -void TreePool::registerStaticNode(TreeNode * node) { -#if 0 - if (nodeID < 0) { - int nodeIndex = indexOfStaticNode(nodeID); - assert(m_staticNodes[nodeIndex] == nullptr && nodeIndex < MaxNumberOfStaticNodes); - m_staticNodes[nodeIndex] = node; - node->rename(nodeID, false); - return; - } -#endif - int generatedNodeIndex = 0; - while (m_staticNodes[generatedNodeIndex] != nullptr && generatedNodeIndex < MaxNumberOfStaticNodes) { - generatedNodeIndex++; - } - assert(generatedNodeIndex < MaxNumberOfStaticNodes); - m_staticNodes[generatedNodeIndex] = node; - node->rename(identifierOfStaticNodeAtIndex(generatedNodeIndex), false); -} -#endif - template T * TreePool::createTreeNode(size_t size) { T * node = new(alloc(size)) T();