From: Timo Sirainen Date: Thu, 29 May 2008 15:47:46 +0000 (+0300) Subject: Sort index: Fix to renumbering sort IDs. X-Git-Tag: 1.1.rc6~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=258464263315a814d8c3f1440058044c62540025;p=thirdparty%2Fdovecot%2Fcore.git Sort index: Fix to renumbering sort IDs. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-sort-string.c b/src/lib-storage/index/index-sort-string.c index 195389c6a9..bad706ce01 100644 --- a/src/lib-storage/index/index-sort-string.c +++ b/src/lib-storage/index/index-sort-string.c @@ -498,18 +498,22 @@ index_sort_add_ids_range(struct sort_string_context *ctx, renumber some of the existing sort IDs. do this by widening the area we're giving sort IDs. */ if (left_idx > 0) { - left_idx--; - left_sort_id = left_idx == 0 ? 1 : - nodes[left_idx].sort_id; - i_assert(left_sort_id != 0); + left_sort_id = nodes[--left_idx].sort_id; + if (left_sort_id == 0) { + i_assert(left_idx == 0); + left_sort_id = 1; + } } while (right_idx < rightmost_idx) { if (nodes[++right_idx].sort_id > 1) break; } - right_sort_id = right_idx == rightmost_idx ? (uint32_t)-1 : - nodes[right_idx].sort_id; + right_sort_id = nodes[right_idx].sort_id; + if (right_sort_id == 0) { + i_assert(right_idx == rightmost_idx); + right_sort_id = (uint32_t)-1; + } i_assert(left_sort_id < right_sort_id); }