diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-07-24 00:40:59 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-07-27 08:07:39 -0400 |
commit | eee85d39e56205976ab8b215e1e3e92e9d8c4913 (patch) | |
tree | 5c831fe370048ebbf0cc53be5af0db522923c150 | |
parent | f7bba525fc7a02443907b5baf365ac09c2009775 (diff) | |
download | gtk+-eee85d39e56205976ab8b215e1e3e92e9d8c4913.tar.gz |
Avoid more GFile<>uri roundtrips
Make GtkSearchHit carry a GFile instead of an uri. Most of the
search engines already have the object around, and converting
to an uri and back is unnecessary extra work.
-rw-r--r-- | gtk/gtkfilechooserwidget.c | 4 | ||||
-rw-r--r-- | gtk/gtksearchengine.c | 8 | ||||
-rw-r--r-- | gtk/gtksearchengine.h | 2 | ||||
-rw-r--r-- | gtk/gtksearchenginemodel.c | 2 | ||||
-rw-r--r-- | gtk/gtksearchenginesimple.c | 2 | ||||
-rw-r--r-- | gtk/gtksearchenginetracker.c | 2 |
6 files changed, 9 insertions, 11 deletions
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 9c51220310..689eaaa085 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -7007,9 +7007,7 @@ search_engine_hits_added_cb (GtkSearchEngine *engine, for (l = hits; l; l = l->next) { GtkSearchHit *hit = (GtkSearchHit *)l->data; - file = g_file_new_for_uri (hit->uri); - if (!file) - continue; + file = g_object_ref (hit->file); if (hit->info) { files_with_info = g_list_prepend (files_with_info, file); diff --git a/gtk/gtksearchengine.c b/gtk/gtksearchengine.c index eff96923aa..fbbb80b0d0 100644 --- a/gtk/gtksearchengine.c +++ b/gtk/gtksearchengine.c @@ -311,7 +311,7 @@ search_hit_equal (gconstpointer a, gconstpointer b) const GtkSearchHit *ha = (const GtkSearchHit *)a; const GtkSearchHit *hb = (const GtkSearchHit *)b; - return g_str_equal (ha->uri, hb->uri); + return g_file_equal (ha->file, hb->file); } @@ -320,7 +320,7 @@ search_hit_hash (gconstpointer a) { const GtkSearchHit *ha = (const GtkSearchHit *)a; - return g_str_hash (ha->uri); + return g_file_hash (ha->file); } GtkSearchHit * @@ -329,7 +329,7 @@ _gtk_search_hit_dup (GtkSearchHit *hit) GtkSearchHit *dup; dup = g_new (GtkSearchHit, 1); - dup->uri = g_strdup (hit->uri); + dup->file = g_object_ref (hit->file); if (hit->info) dup->info = g_object_ref (hit->info); else @@ -341,7 +341,7 @@ _gtk_search_hit_dup (GtkSearchHit *hit) void _gtk_search_hit_free (GtkSearchHit *hit) { - g_free (hit->uri); + g_clear_object (&hit->file); g_clear_object (&hit->info); g_free (hit); } diff --git a/gtk/gtksearchengine.h b/gtk/gtksearchengine.h index e49eeb8c79..c3d181274d 100644 --- a/gtk/gtksearchengine.h +++ b/gtk/gtksearchengine.h @@ -42,7 +42,7 @@ typedef struct _GtkSearchHit GtkSearchHit; struct _GtkSearchHit { - gchar *uri; + GFile *file; GFileInfo *info; /* may be NULL */ }; diff --git a/gtk/gtksearchenginemodel.c b/gtk/gtksearchenginemodel.c index a7f00eec4d..f245e1aa21 100644 --- a/gtk/gtksearchenginemodel.c +++ b/gtk/gtksearchenginemodel.c @@ -99,7 +99,7 @@ do_search (gpointer data) file = _gtk_file_system_model_get_file (model->model, &iter); hit = g_new (GtkSearchHit, 1); - hit->uri = g_file_get_uri (file); + hit->file = g_object_ref (file); hit->info = g_object_ref (info); hits = g_list_prepend (hits, hit); } diff --git a/gtk/gtksearchenginesimple.c b/gtk/gtksearchenginesimple.c index 4db84ce784..1b5a31be96 100644 --- a/gtk/gtksearchenginesimple.c +++ b/gtk/gtksearchenginesimple.c @@ -248,7 +248,7 @@ visit_directory (GFile *dir, SearchThreadData *data) GtkSearchHit *hit; hit = g_new (GtkSearchHit, 1); - hit->uri = g_file_get_uri (child); + hit->file = g_object_ref (child); hit->info = g_object_ref (info); data->hits = g_list_prepend (data->hits, hit); } diff --git a/gtk/gtksearchenginetracker.c b/gtk/gtksearchenginetracker.c index 7c4e063282..bac7a09afd 100644 --- a/gtk/gtksearchenginetracker.c +++ b/gtk/gtksearchenginetracker.c @@ -300,7 +300,7 @@ query_callback (GObject *object, v = g_variant_iter_next_value (&iter); strv = g_variant_get_strv (v, NULL); - hit[i].uri = (gchar*)strv[0]; + hit[i].file = g_file_new_for_uri (strv[0]); hit[i].info = NULL; g_free (strv); hits = g_list_prepend (hits, &hit[i]); |