From 3dcfe43579632f18e7488b4237d43165d0552957 Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Fri, 28 Mar 2008 12:42:27 +0000 Subject: [PATCH] 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 --- src/fe-text/textbuffer.c | 10 +++++++--- 1 file 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) {