apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1664451 - /apr/apr/trunk/tables/apr_skiplist.c
Date Thu, 05 Mar 2015 18:42:35 GMT
Author: ylavic
Date: Thu Mar  5 18:42:35 2015
New Revision: 1664451

URL: http://svn.apache.org/r1664451
Log:
skiplist: Follow up to r1664406+r1664447: Better optimize test in insert_compare() and keep
find_compare() in sync.

Modified:
    apr/apr/trunk/tables/apr_skiplist.c

Modified: apr/apr/trunk/tables/apr_skiplist.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_skiplist.c?rev=1664451&r1=1664450&r2=1664451&view=diff
==============================================================================
--- apr/apr/trunk/tables/apr_skiplist.c (original)
+++ apr/apr/trunk/tables/apr_skiplist.c Thu Mar  5 18:42:35 2015
@@ -312,14 +312,19 @@ static int skiplisti_find_compare(apr_sk
     m = sl->top;
     while (m) {
         int compared;
-        compared = (m->next) ? comp(data, m->next->data) : -1;
-        if (compared == 0) {
-            m = m->next;
-            while (m->down) {
-                m = m->down;
+        if (m->next) {
+            compared = comp(data, m->next->data);
+            if (compared == 0) {
+                m = m->next;
+                while (m->down) {
+                    m = m->down;
+                }
+                *ret = m;
+                return count;
             }
-            *ret = m;
-            return count;
+        }
+        else {
+            compared = -1;
         }
         if (compared < 0) {
             m = m->down;
@@ -419,11 +424,16 @@ static apr_skiplistnode *insert_compare(
     m = sl->top;
     while (m) {
         int compared;
-        compared = (m->next) ? comp(data, m->next->data) : -1;
-        if (compared == 0 && !add) {
-            /* Keep the existing element(s) */
-            skiplist_stack_clear(sl);
-            return NULL;
+        if (m->next) {
+            compared = comp(data, m->next->data);
+            if (compared == 0 && !add) {
+                /* Keep the existing element(s) */
+                skiplist_stack_clear(sl);
+                return NULL;
+            }
+        }
+        else {
+            compared = -1;
         }
         /*
          * To maintain stability, dups must be added AFTER each



Mime
View raw message