[poincare/tree_pool] Factor expression in registerNode

This commit is contained in:
Ruben Dashyan
2019-12-19 14:28:04 +01:00
committed by Léa Saviot
parent 78f1270752
commit ad938aed48

View File

@@ -154,8 +154,9 @@ void TreePool::discardTreeNode(TreeNode * node) {
void TreePool::registerNode(TreeNode * node) {
uint16_t nodeID = node->identifier();
assert(nodeID < MaxNumberOfNodes);
assert((((char *)node) - ((char *)m_alignedBuffer)) / ByteAlignment < k_maxNodeOffset); // Check that the offset can be stored in a uint16_t
m_nodeForIdentifierOffset[nodeID] = (((char *)node) - (char *)m_alignedBuffer)/ByteAlignment;
const int nodeOffset = (((char *)node) - (char *)m_alignedBuffer)/ByteAlignment;
assert(nodeOffset < k_maxNodeOffset); // Check that the offset can be stored in a uint16_t
m_nodeForIdentifierOffset[nodeID] = nodeOffset;
}
void TreePool::updateNodeForIdentifierFromNode(TreeNode * node) {