In the loop we can help the compiler build slightly more efficient code
by placing an unlikely() around the leaf test. This shows a consistent
0.5% performance gain both on eb32 and eb64.
This is ebtree commit
6c9cdbda496837bac1e0738c14e42faa0d1b92c4.
return NULL;
while (1) {
- if ((eb_gettag(troot) == EB_LEAF)) {
+ if (unlikely(eb_gettag(troot) == EB_LEAF)) {
node = container_of(eb_untag(troot, EB_LEAF),
struct eb32_node, node.branches);
if (node->key == x)
return NULL;
while (1) {
- if ((eb_gettag(troot) == EB_LEAF)) {
+ if (unlikely(eb_gettag(troot) == EB_LEAF)) {
node = container_of(eb_untag(troot, EB_LEAF),
struct eb32_node, node.branches);
if (node->key == (u32)x)
return NULL;
while (1) {
- if ((eb_gettag(troot) == EB_LEAF)) {
+ if (unlikely(eb_gettag(troot) == EB_LEAF)) {
node = container_of(eb_untag(troot, EB_LEAF),
struct eb64_node, node.branches);
if (node->key == x)
return NULL;
while (1) {
- if ((eb_gettag(troot) == EB_LEAF)) {
+ if (unlikely(eb_gettag(troot) == EB_LEAF)) {
node = container_of(eb_untag(troot, EB_LEAF),
struct eb64_node, node.branches);
if (node->key == (u64)x)
return NULL;
while (1) {
- if ((eb_gettag(troot) == EB_LEAF)) {
+ if (unlikely(eb_gettag(troot) == EB_LEAF)) {
/* We reached a leaf, which means that the whole upper
* parts were common. We will return either the current
* node or its next one if the former is too small.
return NULL;
while (1) {
- if ((eb_gettag(troot) == EB_LEAF)) {
+ if (unlikely(eb_gettag(troot) == EB_LEAF)) {
/* We reached a leaf, which means that the whole upper
* parts were common. We will return either the current
* node or its next one if the former is too small.
return NULL;
while (1) {
- if ((eb_gettag(troot) == EB_LEAF)) {
+ if (unlikely(eb_gettag(troot) == EB_LEAF)) {
/* We reached a leaf, which means that the whole upper
* parts were common. We will return either the current
* node or its next one if the former is too small.
return NULL;
while (1) {
- if ((eb_gettag(troot) == EB_LEAF)) {
+ if (unlikely(eb_gettag(troot) == EB_LEAF)) {
/* We reached a leaf, which means that the whole upper
* parts were common. We will return either the current
* node or its next one if the former is too small.