[gnome-control-center] shell: Keep the filter terms cached
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] shell: Keep the filter terms cached
- Date: Fri, 16 May 2014 10:00:47 +0000 (UTC)
commit 98a2ab2603a8fe905fa1144c5de818a60fe75cb6
Author: Rui Matos <tiagomatos gmail com>
Date: Sat Apr 26 21:02:56 2014 +0200
shell: Keep the filter terms cached
This avoids calling g_strsplit() for every model item when filtering.
https://bugzilla.gnome.org/show_bug.cgi?id=729027
shell/cc-window.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/shell/cc-window.c b/shell/cc-window.c
index 29b28e6..d091e79 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -97,6 +97,7 @@ struct _CcWindowPrivate
GtkTreeModel *search_filter;
GtkWidget *search_view;
gchar *filter_string;
+ gchar **filter_terms;
CcPanel *active_panel;
@@ -564,14 +565,13 @@ model_filter_func (GtkTreeModel *model,
GtkTreeIter *iter,
CcWindowPrivate *priv)
{
- char **terms, **t;
+ char **t;
gboolean matches = FALSE;
- if (!priv->filter_string)
+ if (!priv->filter_string || !priv->filter_terms)
return FALSE;
- terms = g_strsplit (priv->filter_string, " ", -1);
- for (t = terms; *t; t++)
+ for (t = priv->filter_terms; *t; t++)
{
matches = cc_shell_model_iter_matches_search (CC_SHELL_MODEL (model),
iter,
@@ -579,7 +579,6 @@ model_filter_func (GtkTreeModel *model,
if (!matches)
break;
}
- g_strfreev (terms);
return matches;
}
@@ -619,6 +618,9 @@ search_entry_changed_cb (GtkEntry *entry,
g_free (priv->filter_string);
priv->filter_string = str;
+ g_strfreev (priv->filter_terms);
+ priv->filter_terms = g_strsplit (priv->filter_string, " ", -1);
+
if (!g_strcmp0 (priv->filter_string, ""))
{
shell_show_overview_page (center);
@@ -1168,6 +1170,7 @@ cc_window_finalize (GObject *object)
CcWindowPrivate *priv = CC_WINDOW (object)->priv;
g_free (priv->filter_string);
+ g_strfreev (priv->filter_terms);
G_OBJECT_CLASS (cc_window_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]