summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2008-03-28 12:42:27 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2008-03-28 12:42:27 +0000
commit3dcfe43579632f18e7488b4237d43165d0552957 (patch)
treec836570d217a3b2b2b63baacca67430edebc07a7
parentbe3818930ad9e09d972df7712fa08046c96b316e (diff)
downloadirssi-3dcfe43579632f18e7488b4237d43165d0552957.zip
Move selection of string searching function out of the loop by using a
function pointer. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4777 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/fe-text/textbuffer.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c
index 46251564..5be6c60a 100644
--- a/src/fe-text/textbuffer.c
+++ b/src/fe-text/textbuffer.c
@@ -512,6 +512,7 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
GList *matches;
GString *str;
int i, match_after, line_matched;
+ char * (*match_func)(const char *, const char *);
g_return_val_if_fail(buffer != NULL, NULL);
g_return_val_if_fail(text != NULL, NULL);
@@ -532,6 +533,11 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
line = startline != NULL ? startline : buffer->first_line;
+ if (fullword)
+ match_func = case_sensitive ? strstr_full : stristr_full;
+ else
+ match_func = case_sensitive ? strstr : stristr;
+
for (; line != NULL; line = line->next) {
line_matched = (line->info.level & level) != 0 &&
(line->info.level & nolevel) == 0;
@@ -544,9 +550,7 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
#ifdef HAVE_REGEX_H
regexp ? regexec(&preg, str->str, 0, NULL, 0) == 0 :
#endif
- fullword ? strstr_full_case(str->str, text, !case_sensitive) != NULL :
- case_sensitive ? strstr(str->str, text) != NULL :
- stristr(str->str, text) != NULL;
+ match_func(str->str, text) != NULL;
}
if (line_matched) {