[gnome-commander] search: simplify code for content_matches() function



commit 0631b16fc93441b85b0bc11ca13cb10df7928615
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Mon May 16 19:22:55 2011 +0200

    search: simplify code for content_matches() function

 src/dialogs/gnome-cmd-search-dialog.cc |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)
---
diff --git a/src/dialogs/gnome-cmd-search-dialog.cc b/src/dialogs/gnome-cmd-search-dialog.cc
index 2b62c80..51f0c79 100755
--- a/src/dialogs/gnome-cmd-search-dialog.cc
+++ b/src/dialogs/gnome-cmd-search-dialog.cc
@@ -228,23 +228,14 @@ inline gboolean content_matches (GnomeCmdFile *f, SearchData *data)
     g_return_val_if_fail (f != NULL, FALSE);
     g_return_val_if_fail (f->info != NULL, FALSE);
 
-    gint ret = REG_NOMATCH;
+    regmatch_t match;
 
     if (f->info->size > 0)
-    {
-        regmatch_t       match;
-        SearchFileData  *search_file = NULL;
-
-        while ((search_file = read_search_file (data, search_file, f)))
-        {
-            ret = regexec (data->content_regex, data->search_mem, 1, &match, 0);
-            // stop on first match
-            if (ret != REG_NOMATCH)
-                break;
-        }
-    }
+        for (SearchFileData *search_file=NULL; (search_file = read_search_file (data, search_file, f)); )
+            if (regexec (data->content_regex, data->search_mem, 1, &match, 0) != REG_NOMATCH)
+                return TRUE;        // stop on first match
 
-    return ret != REG_NOMATCH;
+    return FALSE;
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]