From: Arran Cudbard-Bell Date: Sat, 6 Nov 2021 15:04:03 +0000 (-0400) Subject: Revert "Remove hot branch in rbtree find_node" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a342b56ee20f159721c074151093c2433689aff1;p=thirdparty%2Ffreeradius-server.git Revert "Remove hot branch in rbtree find_node" This reverts commit b19a7ac6737e7a0f0aefb20cd94d9441d0e0eb3c. --- diff --git a/src/lib/util/rb.c b/src/lib/util/rb.c index 68d8c9ae9b0..738aad1080a 100644 --- a/src/lib/util/rb.c +++ b/src/lib/util/rb.c @@ -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; diff --git a/src/lib/util/rb.h b/src/lib/util/rb.h index cfcab49945b..9c26a2ff307 100644 --- a/src/lib/util/rb.h +++ b/src/lib/util/rb.h @@ -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