]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Refactor fix_iterator
authorMatthijs Mekking <matthijs@isc.org>
Fri, 10 May 2024 15:19:15 +0000 (17:19 +0200)
committerEvan Hunt <each@isc.org>
Tue, 14 May 2024 19:58:46 +0000 (12:58 -0700)
The code below the if/else construction could only be run if the 'if'
code path was taken. Move the code into the 'if' code block so that
it is more easier to read.

lib/dns/qp.c

index e8ff8f66a7828d37f6717694b0f83ccd36f5d683..3f8b0ec2938fac89c516796854d72269cb04cf51 100644 (file)
@@ -2148,6 +2148,19 @@ fix_iterator(dns_qpreader_t *qp, dns_qpiter_t *iter, dns_qpkey_t search,
 
                        RUNTIME_CHECK(result == ISC_R_SUCCESS);
                        n = iter->stack[iter->sp];
+
+                       foundlen = leaf_qpkey(qp, n, found);
+                       size_t nto = qpkey_compare(search, searchlen, found,
+                                                  foundlen);
+                       if (nto < to) {
+                               /*
+                                * We've moved to a new leaf and it differs at
+                                * an even earlier point, so no further
+                                * improvement is possible.
+                                */
+                               return;
+                       }
+                       to = nto;
                } else {
                        if (to <= searchlen && to <= foundlen && iter->sp > 0) {
                                /*
@@ -2187,18 +2200,6 @@ fix_iterator(dns_qpreader_t *qp, dns_qpiter_t *iter, dns_qpkey_t search,
 
                        return;
                }
-
-               foundlen = leaf_qpkey(qp, n, found);
-               size_t nto = qpkey_compare(search, searchlen, found, foundlen);
-               if (nto < to) {
-                       /*
-                        * We've moved to a new leaf and it differs at an
-                        * even earlier point, so no further improvement is
-                        * possible.
-                        */
-                       return;
-               }
-               to = nto;
        }
 
        if (is_branch(n)) {