The branch main has been updated by dougm:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0d965bc03428b66689d311fa4275868dfe27c82e

commit 0d965bc03428b66689d311fa4275868dfe27c82e
Author:     Doug Moore <do...@freebsd.org>
AuthorDate: 2024-10-25 22:00:31 +0000
Commit:     Doug Moore <do...@freebsd.org>
CommitDate: 2024-10-25 22:00:31 +0000

    subr_pctrie: improve iter nbr search
    
    pctrie_toval(node) can be applied to either a leaf or an internal
    node; in the latter case it provides the address of the pn_owner
    field. In a couple of places where a neighbor search is about to begin
    for an iterator, the current code distinguishes the leaf and non-leaf
    cases in a way that isn't really necessary. This change shrinks each
    function by 16 bytes, and by a branch instruction.
    
    Reviewed by:    bnovkov
    Differential Revision:  https://reviews.freebsd.org/D47207
---
 sys/kern/subr_pctrie.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c
index ea1c1cf881d2..e4865c602ce4 100644
--- a/sys/kern/subr_pctrie.c
+++ b/sys/kern/subr_pctrie.c
@@ -801,9 +801,7 @@ pctrie_iter_lookup_ge(struct pctrie_iter *it, uint64_t 
index)
         * If no such node was found, and instead this path leads only to nodes
         * < index, back up to find a subtrie with the least value > index.
         */
-       if (pctrie_isleaf(node) ?
-           (m = pctrie_toval(node)) == NULL || *m < index :
-           node->pn_owner < index) {
+       if (node == PCTRIE_NULL || *pctrie_toval(node) < index) {
                /* Climb the path to find a node with a descendant > index. */
                while (it->top != 0) {
                        node = it->path[it->top - 1];
@@ -960,9 +958,7 @@ pctrie_iter_lookup_le(struct pctrie_iter *it, uint64_t 
index)
         * If no such node was found, and instead this path leads only to nodes
         * > index, back up to find a subtrie with the greatest value < index.
         */
-       if (pctrie_isleaf(node) ?
-           (m = pctrie_toval(node)) == NULL || *m > index :
-           node->pn_owner > index) {
+       if (node == PCTRIE_NULL || *pctrie_toval(node) > index) {
                /* Climb the path to find a node with a descendant < index. */
                while (it->top != 0) {
                        node = it->path[it->top - 1];

Reply via email to