]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fewer name copies in step
authorAlessio Podda <alessio@isc.org>
Sun, 14 Dec 2025 13:21:52 +0000 (14:21 +0100)
committerOndřej Surý <ondrej@isc.org>
Thu, 12 Feb 2026 16:32:34 +0000 (17:32 +0100)
Part of an refactor to eliminate intermediate copies in qpzone_find.

lib/dns/qpzone.c

index 7f6cda8c3c4c25f2beb692847f862962321e4b71..e73f06ef7db2e5956733a641c842ac2a6f11d9ee 100644 (file)
@@ -2642,16 +2642,13 @@ typedef enum { FORWARD, BACK } direction_t;
 static bool
 step(qpz_search_t *search, dns_qpiter_t *it, direction_t direction,
      dns_name_t *nextname) {
-       dns_fixedname_t fnodename;
-       dns_name_t *nodename = dns_fixedname_initname(&fnodename);
-       qpznode_t *node = NULL;
+       qpznode_t *node = NULL, *previous_node = NULL;
        isc_result_t result = ISC_R_SUCCESS;
 
        result = dns_qpiter_current(it, (void **)&node, NULL);
-       if (result == ISC_R_SUCCESS) {
-               dns_name_copy(&node->name, nodename);
-       }
        while (result == ISC_R_SUCCESS) {
+               previous_node = node;
+
                isc_rwlock_t *nlock = qpzone_get_lock(node);
                isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
                dns_vecheader_t *found = NULL;
@@ -2670,13 +2667,11 @@ step(qpz_search_t *search, dns_qpiter_t *it, direction_t direction,
                } else {
                        result = dns_qpiter_prev(it, (void **)&node, NULL);
                }
-               if (result == ISC_R_SUCCESS) {
-                       dns_name_copy(&node->name, nodename);
-               }
        };
+
        if (result == ISC_R_SUCCESS) {
-               if (nextname != NULL) {
-                       dns_name_copy(nodename, nextname);
+               if (previous_node != NULL) {
+                       dns_name_copy(&previous_node->name, nextname);
                }
                return true;
        }