You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2015/03/05 19:42:35 UTC
svn commit: r1664451 - /apr/apr/trunk/tables/apr_skiplist.c
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