[srvx-commits] CVS: services/src dict-splay.c,1.10,1.11
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2002-10-31 03:44:48
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv10413/src
Modified Files:
dict-splay.c
Log Message:
remove extra calls to irccasecmp()
simplify dict_remove2() function
make dict_find(NULL, *, *) return NULL
Index: dict-splay.c
===================================================================
RCS file: /cvsroot/srvx/services/src/dict-splay.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** dict-splay.c 15 Aug 2002 03:50:09 -0000 1.10
--- dict-splay.c 31 Oct 2002 03:44:45 -0000 1.11
***************
*** 155,160 ****
new_node->r = dict->root;
dict->root->l = NULL;
! if (dict->root->prev) dict->root->prev->next = new_node;
! if (irccasecmp(key, dict->first->key) < 0) dict->first = new_node;
new_node->prev = dict->root->prev;
new_node->next = dict->root;
--- 155,163 ----
new_node->r = dict->root;
dict->root->l = NULL;
! if (dict->root->prev) {
! dict->root->prev->next = new_node;
! } else {
! dict->first = new_node;
! }
new_node->prev = dict->root->prev;
new_node->next = dict->root;
***************
*** 166,171 ****
new_node->l = dict->root;
dict->root->r = NULL;
! if (dict->root->next) dict->root->next->prev = new_node;
! if (irccasecmp(key, dict->last->key) > 0) dict->last = new_node;
new_node->next = dict->root->next;
new_node->prev = dict->root;
--- 169,177 ----
new_node->l = dict->root;
dict->root->r = NULL;
! if (dict->root->next) {
! dict->root->next->prev = new_node;
! } else {
! dict->last = new_node;
! }
new_node->next = dict->root->next;
new_node->prev = dict->root;
***************
*** 198,224 ****
dict_remove2(dict_t dict, const char *key, int no_dispose)
{
dict->root = dict_splay(dict->root, key);
! if (dict->root && !irccasecmp(key, dict->root->key)) {
! struct dict_node *new_root;
! if (!dict->root->l) {
! new_root = dict->root->r;
! } else {
! new_root = dict_splay(dict->root->l, key);
! new_root->r = dict->root->r;
! }
! if (dict->root->prev) dict->root->prev->next = dict->root->next;
! if (dict->first == dict->root) dict->first = dict->first->next;
! if (dict->root->next) dict->root->next->prev = dict->root->prev;
! if (dict->last == dict->root) dict->last = dict->last->prev;
! if (no_dispose) {
! free(dict->root);
! } else {
! dict_dispose_node(dict->root, dict->free_keys, dict->free_data);
! }
! dict->root = new_root;
! dict->count--;
! return 1;
}
! return 0;
}
--- 204,231 ----
dict_remove2(dict_t dict, const char *key, int no_dispose)
{
+ struct dict_node *new_root;
+
+ if (!dict->root) return 0;
dict->root = dict_splay(dict->root, key);
! if (irccasecmp(key, dict->root->key)) return 0;
!
! if (!dict->root->l) {
! new_root = dict->root->r;
! } else {
! new_root = dict_splay(dict->root->l, key);
! new_root->r = dict->root->r;
! }
! if (dict->root->prev) dict->root->prev->next = dict->root->next;
! if (dict->first == dict->root) dict->first = dict->first->next;
! if (dict->root->next) dict->root->next->prev = dict->root->prev;
! if (dict->last == dict->root) dict->last = dict->last->prev;
! if (no_dispose) {
! free(dict->root);
! } else {
! dict_dispose_node(dict->root, dict->free_keys, dict->free_data);
}
! dict->root = new_root;
! dict->count--;
! return 1;
}
***************
*** 233,237 ****
{
int was_found;
! if (!dict->root || !key) {
if (found) *found = 0;
return NULL;
--- 240,244 ----
{
int was_found;
! if (!dict || !dict->root || !key) {
if (found) *found = 0;
return NULL;
|