]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
zone: optimization of a frequently used function
authorLibor Peltan <libor.peltan@nic.cz>
Tue, 5 Mar 2019 18:15:42 +0000 (19:15 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Fri, 26 Apr 2019 12:39:59 +0000 (14:39 +0200)
src/knot/zone/node.c
src/knot/zone/node.h

index 4194665bb9a03a73c8164ae0ab072249f37bd99b..88bfa69f62790240254eddd9b2e06eb66fbe63e1 100644 (file)
@@ -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)
index 52823f4ed1537af5bf812c3e354702ade02115b9..c13ccacef2ec2b342ac070f0dc7b52a7e20bc2be 100644 (file)
@@ -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,
 };