Commit 87e5ecd8 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

simplifying method ngx_rbtree_generic_insert to use same logic of...

simplifying method ngx_rbtree_generic_insert to use same logic of *_rbtree_insert_value nginx methods
parent c0bec585
......@@ -227,36 +227,25 @@ ngx_http_push_stream_get_channel(ngx_str_t *id, ngx_log_t *log, ngx_http_push_st
static void
ngx_rbtree_generic_insert(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel, int (*compare) (const ngx_rbtree_node_t *left, const ngx_rbtree_node_t *right))
{
ngx_rbtree_node_t **p;
for (;;) {
if (node->key < temp->key) {
if (temp->left == sentinel) {
temp->left = node;
break;
}
temp = temp->left;
p = &temp->left;
} else if (node->key > temp->key) {
if (temp->right == sentinel) {
temp->right = node;
break;
}
temp = temp->right;
p = &temp->right;
} else { /* node->key == temp->key */
if (compare(node, temp) < 0) {
if (temp->left == sentinel) {
temp->left = node;
break;
p = (compare(node, temp) < 0) ? &temp->left : &temp->right;
}
temp = temp->left;
} else {
if (temp->right == sentinel) {
temp->right = node;
if (*p == sentinel) {
break;
}
temp = temp->right;
}
}
temp = *p;
}
*p = node;
node->parent = temp;
node->left = sentinel;
node->right = sentinel;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment