]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Revert "Remove hot branch in rbtree find_node"
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 6 Nov 2021 15:04:03 +0000 (11:04 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 6 Nov 2021 15:04:03 +0000 (11:04 -0400)
This reverts commit b19a7ac6737e7a0f0aefb20cd94d9441d0e0eb3c.

src/lib/util/rb.c
src/lib/util/rb.h

index 68d8c9ae9b054ad21f5c06e789ccded2a6cc1f76..738aad1080a83e93b4221f0b5da263a85561756b 100644 (file)
@@ -557,16 +557,7 @@ static inline CC_HINT(always_inline) fr_rb_node_t *find_node(fr_rb_tree_t const
 
                if (result == 0) return current;
 
-               /*
-                *      If result > 0, return the start of the struct
-                *      i.e. the left branch.
-                *
-                *      If result < 0, return struct + sizeof(fr_rb_node_t)
-                *      i.e. the right branch.
-                *
-                *      One fewer branch in the hot loop...
-                */
-               current = *(fr_rb_node_t **)((uint8_t *)current + ((result > 0) * sizeof(fr_rb_node_t *)));
+               current = (result < 0) ? current->left : current->right;
        }
 
        return NULL;
index cfcab49945b40335e89da40df94adefcb3b837bc..9c26a2ff30723ff3940a6faa10ae302d3f69c785 100644 (file)
@@ -39,9 +39,9 @@ typedef enum {
 } fr_rb_colour_t;
 
 typedef struct fr_rb_node_s fr_rb_node_t;
-struct CC_HINT(packed) fr_rb_node_s {
-       fr_rb_node_t            *left;          //!< Left child - Must occur first in the struct.
-       fr_rb_node_t            *right;         //!< Right child - Must occur second in the struct.
+struct fr_rb_node_s {
+       fr_rb_node_t            *left;          //!< Left child
+       fr_rb_node_t            *right;         //!< Right child
        fr_rb_node_t            *parent;        //!< Parent
        void                    *data;          //!< data stored in node