summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2017-06-07 00:15:45 +0200
committerGitHub <noreply@github.com>2017-06-07 00:15:45 +0200
commit3246001fb4e6800d9385b2e3e0314abd20118ce7 (patch)
tree47ababac06f6c57a5e94b6a0420ca208bce8a470
parent5e9a3ad80cb1bb5b8655d5fff6ee9d1dfc4419a1 (diff)
parente498265328bd619b231ea4c985734ea43bf89696 (diff)
downloadirssi-3246001fb4e6800d9385b2e3e0314abd20118ce7.zip
Merge pull request #715 from dequis/lastlog-glist-performance
Performance improvements for /lastlog
-rw-r--r--src/fe-text/textbuffer.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c
index 3668f4c7..1f587f97 100644
--- a/src/fe-text/textbuffer.c
+++ b/src/fe-text/textbuffer.c
@@ -610,27 +610,30 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
pre_line = line;
for (i = 0; i < before; i++) {
if (pre_line->prev == NULL ||
- g_list_find(matches, pre_line->prev) != NULL)
+ g_list_nth_data(matches, 0) == pre_line->prev ||
+ g_list_nth_data(matches, 1) == pre_line->prev)
break;
pre_line = pre_line->prev;
}
for (; pre_line != line; pre_line = pre_line->next)
- matches = g_list_append(matches, pre_line);
+ matches = g_list_prepend(matches, pre_line);
match_after = after;
}
if (line_matched || match_after > 0) {
/* matched */
- matches = g_list_append(matches, line);
+ matches = g_list_prepend(matches, line);
if ((!line_matched && --match_after == 0) ||
(line_matched && match_after == 0 && before > 0))
- matches = g_list_append(matches, NULL);
+ matches = g_list_prepend(matches, NULL);
}
}
+ matches = g_list_reverse(matches);
+
#ifdef USE_GREGEX
if (preg != NULL)
g_regex_unref(preg);