mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-22 12:30:07 +00:00
OPTIM: ebtree: make ebmb_insert_prefix() keep a copy the new node's key
Similarly to the previous patch, it's better to keep a local copy of the new node's key instead of accessing it every time. This slightly reduces the code's size in the descent and further improves the load time to 7.45s.
This commit is contained in:
parent
bf13e53964
commit
91d31c9e1c
@ -620,6 +620,7 @@ __ebmb_insert_prefix(struct eb_root *root, struct ebmb_node *new, unsigned int l
|
|||||||
int old_node_bit;
|
int old_node_bit;
|
||||||
unsigned int npfx = new->node.pfx;
|
unsigned int npfx = new->node.pfx;
|
||||||
unsigned int npfx1 = npfx << 1;
|
unsigned int npfx1 = npfx << 1;
|
||||||
|
const unsigned char *nkey = new->key;
|
||||||
|
|
||||||
side = EB_LEFT;
|
side = EB_LEFT;
|
||||||
troot = root->b[EB_LEFT];
|
troot = root->b[EB_LEFT];
|
||||||
@ -679,13 +680,13 @@ __ebmb_insert_prefix(struct eb_root *root, struct ebmb_node *new, unsigned int l
|
|||||||
/* No need to compare everything if the leaves are shorter than the new one. */
|
/* No need to compare everything if the leaves are shorter than the new one. */
|
||||||
if (len > old->node.pfx)
|
if (len > old->node.pfx)
|
||||||
len = old->node.pfx;
|
len = old->node.pfx;
|
||||||
bit = equal_bits(new->key, old->key, bit, len);
|
bit = equal_bits(nkey, old->key, bit, len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WARNING: for the two blocks below, <bit> is counted in half-bits */
|
/* WARNING: for the two blocks below, <bit> is counted in half-bits */
|
||||||
|
|
||||||
bit = equal_bits(new->key, old->key, bit, old_node_bit >> 1);
|
bit = equal_bits(nkey, old->key, bit, old_node_bit >> 1);
|
||||||
bit = (bit << 1) + 1; // assume comparisons with normal nodes
|
bit = (bit << 1) + 1; // assume comparisons with normal nodes
|
||||||
|
|
||||||
/* we must always check that our prefix is larger than the nodes
|
/* we must always check that our prefix is larger than the nodes
|
||||||
@ -710,7 +711,7 @@ __ebmb_insert_prefix(struct eb_root *root, struct ebmb_node *new, unsigned int l
|
|||||||
new->node.node_p = old->node.node_p;
|
new->node.node_p = old->node.node_p;
|
||||||
up_ptr = &old->node.node_p;
|
up_ptr = &old->node.node_p;
|
||||||
new->node.bit = bit;
|
new->node.bit = bit;
|
||||||
diff = cmp_bits(new->key, old->key, bit >> 1);
|
diff = cmp_bits(nkey, old->key, bit >> 1);
|
||||||
goto insert_above;
|
goto insert_above;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,7 +747,7 @@ __ebmb_insert_prefix(struct eb_root *root, struct ebmb_node *new, unsigned int l
|
|||||||
root = &old->node.branches;
|
root = &old->node.branches;
|
||||||
side = old_node_bit & 7;
|
side = old_node_bit & 7;
|
||||||
side ^= 7;
|
side ^= 7;
|
||||||
side = (new->key[old_node_bit >> 3] >> side) & 1;
|
side = (nkey[old_node_bit >> 3] >> side) & 1;
|
||||||
troot = root->b[side];
|
troot = root->b[side];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,7 +790,7 @@ __ebmb_insert_prefix(struct eb_root *root, struct ebmb_node *new, unsigned int l
|
|||||||
*/
|
*/
|
||||||
diff = 0;
|
diff = 0;
|
||||||
if (bit < old->node.pfx && bit < npfx)
|
if (bit < old->node.pfx && bit < npfx)
|
||||||
diff = cmp_bits(new->key, old->key, bit);
|
diff = cmp_bits(nkey, old->key, bit);
|
||||||
|
|
||||||
if (diff == 0) {
|
if (diff == 0) {
|
||||||
/* Both keys match. Either it's a duplicate entry or we have to
|
/* Both keys match. Either it's a duplicate entry or we have to
|
||||||
|
Loading…
Reference in New Issue
Block a user