From d12ebcef82d274aef0930c94ba90b2b40d91828c Mon Sep 17 00:00:00 2001 From: default Date: Fri, 10 May 2024 12:22:36 +0200 Subject: [PATCH] More search tweaks MUAHAHAHA. --- data.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/data.c b/data.c index 60eda25..d037af0 100644 --- a/data.c +++ b/data.c @@ -2499,10 +2499,8 @@ xs_list *content_search(snac *user, const char *regex, return xs_list_new(); xs_set seen; - xs_set skipped; xs_set_init(&seen); - xs_set_init(&skipped); if (max_secs == 0) max_secs = 3; @@ -2523,6 +2521,8 @@ xs_list *content_search(snac *user, const char *regex, xs_list_next(pub_tl, &pub_md5, &pub_c); xs_list_next(priv_tl, &priv_md5, &priv_c); + show += skip; + while (show > 0) { char *md5 = NULL; enum { NONE, PUBLIC, PRIVATE } from = NONE; @@ -2594,20 +2594,21 @@ xs_list *content_search(snac *user, const char *regex, xs *l = xs_regex_select_n(c, regex, 1); if (xs_list_len(l)) { - if (skip > 0) { - if (xs_set_add(&skipped, md5) == 1) - skip--; - } - else { - if (xs_set_add(&seen, md5) == 1) - show--; - } + if (xs_set_add(&seen, md5) == 1) + show--; } } - xs_set_free(&skipped); + xs_list *r = xs_set_result(&seen); - return xs_set_result(&seen); + if (skip) { + /* BAD */ + while (skip--) { + r = xs_list_del(r, 0); + } + } + + return r; }