Commit de20da61 authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman

zone: optimization of a frequently used function

parent 8ab0459c
......@@ -193,15 +193,10 @@ int binode_prepare_change(zone_node_t *node, knot_mm_t *mm)
zone_node_t *binode_node(zone_node_t *node, bool second)
{
if (node != NULL && (node->flags & NODE_FLAGS_BINODE)) {
if (second && !(node->flags & NODE_FLAGS_SECOND)) {
return node + 1;
}
if (!second && (node->flags & NODE_FLAGS_SECOND)) {
return node - 1;
}
if (unlikely(node == NULL || !(node->flags & NODE_FLAGS_BINODE))) {
return node;
}
return node;
return node + (second - (int)((node->flags & NODE_FLAGS_SECOND) >> 9));
}
bool binode_rdata_shared(zone_node_t *node, uint16_t type)
......
......@@ -85,9 +85,9 @@ enum node_flags {
/*! \brief Node is the zone Apex. */
NODE_FLAGS_APEX = 1 << 6,
/*! \brief Is this i bi-node? */
NODE_FLAGS_BINODE = 1 << 8,
NODE_FLAGS_BINODE = 1 << 8, // this value shall be fixed
/*! \brief Is this the second half of bi-node? */
NODE_FLAGS_SECOND = 1 << 9,
NODE_FLAGS_SECOND = 1 << 9, // this value shall be fixed
/*! \brief The node shall be deleted. It's just not because it's a bi-node and the counterpart still exists. */
NODE_FLAGS_DELETED = 1 << 10,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment