[poincare] Inline TreePool::node(identifier)

This commit is contained in:
Léa Saviot
2018-08-30 10:20:20 +02:00
parent 75f575c7d9
commit 2872815ee7
2 changed files with 9 additions and 11 deletions

View File

@@ -24,7 +24,15 @@ public:
static TreePool * sharedPool();
// Node
TreeNode * node(int identifier) const;
TreeNode * node(int identifier) const {
if (identifier <= TreeNode::FirstStaticNodeIdentifier) {
int index = indexOfStaticNode(identifier);
assert(index >= 0 && index < MaxNumberOfStaticNodes);
return m_staticNodes[index];
}
assert(identifier >= 0 && identifier <= MaxNumberOfNodes);
return m_nodeForIdentifier[identifier];
}
TreeNode * last() const { return reinterpret_cast<TreeNode *>(const_cast<char *>(m_cursor)); }
template <typename T>

View File

@@ -10,16 +10,6 @@ TreePool * TreePool::sharedPool() {
return &pool;
}
TreeNode * TreePool::node(int identifier) const {
if (identifier <= FirstStaticNodeIdentifier) {
int index = indexOfStaticNode(identifier);
assert(index >= 0 && index < MaxNumberOfStaticNodes);
return m_staticNodes[index];
}
assert(identifier >= 0 && identifier <= MaxNumberOfNodes);
return m_nodeForIdentifier[identifier];
}
static void memmove32(uint32_t * dst, uint32_t * src, size_t len) {
if (src < dst && dst < src + len) {
/* Copy backwards to avoid overwrites */