From: Libor Peltan Date: Tue, 5 Mar 2019 18:15:42 +0000 (+0100) Subject: zone: optimization of a frequently used function X-Git-Tag: v2.9.0~286^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de20da61f5d5b07e2bb349af04c8a3859c6d9ae8;p=thirdparty%2Fknot-dns.git zone: optimization of a frequently used function --- diff --git a/src/knot/zone/node.c b/src/knot/zone/node.c index 4194665bb9..88bfa69f62 100644 --- a/src/knot/zone/node.c +++ b/src/knot/zone/node.c @@ -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) diff --git a/src/knot/zone/node.h b/src/knot/zone/node.h index 52823f4ed1..c13ccacef2 100644 --- a/src/knot/zone/node.h +++ b/src/knot/zone/node.h @@ -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, };