From 4c89b0e80c730b93caad3e68541a527e6c4f759f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 26 Sep 2005 08:21:10 +0000 Subject: [PATCH] Tweak branches in avl_find --- libraries/liblutil/avl.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libraries/liblutil/avl.c b/libraries/liblutil/avl.c index fecb8d2faa..e5a5153d08 100644 --- a/libraries/liblutil/avl.c +++ b/libraries/liblutil/avl.c @@ -528,10 +528,8 @@ avl_find2( Avlnode *root, const void *data, AVL_CMP fcmp ) int cmp; while ( root != 0 && (cmp = (*fcmp)( data, root->avl_data )) != 0 ) { - if ( cmp < 0 ) - root = root->avl_left; - else - root = root->avl_right; + cmp = cmp > 0; + root = root->avl_link[cmp]; } return root; } @@ -542,10 +540,8 @@ avl_find( Avlnode *root, const void* data, AVL_CMP fcmp ) int cmp; while ( root != 0 && (cmp = (*fcmp)( data, root->avl_data )) != 0 ) { - if ( cmp < 0 ) - root = root->avl_left; - else - root = root->avl_right; + cmp = cmp > 0; + root = root->avl_link[cmp]; } return( root ? root->avl_data : 0 ); -- 2.39.5