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 ...@@ -227,36 +227,25 @@ ngx_http_push_stream_get_channel(ngx_str_t *id, ngx_log_t *log, ngx_http_push_st
static void 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_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 (;;) { for (;;) {
if (node->key < temp->key) { if (node->key < temp->key) {
if (temp->left == sentinel) { p = &temp->left;
temp->left = node;
break;
}
temp = temp->left;
} else if (node->key > temp->key) { } else if (node->key > temp->key) {
if (temp->right == sentinel) { p = &temp->right;
temp->right = node;
break;
}
temp = temp->right;
} else { /* node->key == temp->key */ } else { /* node->key == temp->key */
if (compare(node, temp) < 0) { p = (compare(node, temp) < 0) ? &temp->left : &temp->right;
if (temp->left == sentinel) { }
temp->left = node;
break; if (*p == sentinel) {
} break;
temp = temp->left;
} else {
if (temp->right == sentinel) {
temp->right = node;
break;
}
temp = temp->right;
}
} }
temp = *p;
} }
*p = node;
node->parent = temp; node->parent = temp;
node->left = sentinel; node->left = sentinel;
node->right = 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