From a5f2b33412d10ea2de178a45b734d9961c487aee Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 11 Sep 2008 09:26:56 +0200 Subject: [PATCH] Simplify a bit . Removed obsolete comment --- index/zsets.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/index/zsets.c b/index/zsets.c index 225876c..b81dce6 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -578,6 +578,9 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, wrbuf_rewind(w); if (zebra_sort_read(zh->reg->sort_index, w)) { + /* consider each sort entry and take lowest/highest one + of the one as sorting key depending on whether sort is + ascending/descending */ int off = 0; while (off != wrbuf_len(w)) { @@ -586,27 +589,16 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, if (l >= SORT_IDX_ENTRYSIZE) l = SORT_IDX_ENTRYSIZE-1; - if (off == 0) + if ( (off == 0) + || (criteria[i].relation == 'A' + && strcmp(wrbuf_buf(w)+off, this_entry_buf) < 0) + || (criteria[i].relation == 'D' + && strcmp(wrbuf_buf(w)+off, this_entry_buf) > 0) + ) { memcpy(this_entry_buf, wrbuf_buf(w)+off, l); this_entry_buf[l] = '\0'; } - else if (criteria[i].relation == 'A') - { - if (strcmp(wrbuf_buf(w)+off, this_entry_buf) < 0) - { - memcpy(this_entry_buf, wrbuf_buf(w)+off, l); - this_entry_buf[l] = '\0'; - } - } - else if (criteria[i].relation == 'D') - { - if (strcmp(wrbuf_buf(w)+off, this_entry_buf) > 0) - { - memcpy(this_entry_buf, wrbuf_buf(w)+off, l); - this_entry_buf[l] = '\0'; - } - } off += 1 + strlen(wrbuf_buf(w)+off); } } @@ -631,12 +623,6 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, char this_entry_org[1024]; char other_entry_org[1024]; double diff; - /* when searching multiple databases, we use the index - type of the first one. So if they differ between - databases, we have a problem here we could store the - index_type for each database, but if we didn't find the - record in any sort index, then we still don't know to - which database it belongs. */ const char *index_type = criteria[j].index_type; zebra_term_untrans(zh, index_type, this_entry_org, this_entry_buf); -- 1.7.10.4