diff options
author | Jan-Michael Brummer <jan.brummer@tabos.org> | 2020-03-15 15:26:53 +0100 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@gnome.org> | 2020-04-12 19:43:03 +0000 |
commit | f849a27760a2e01b38b2c46314f45743eb7a6af3 (patch) | |
tree | a7c6e920f1bea6a68c7301cacbe6a50042c63b29 | |
parent | 6e171207ea1af6e73e89fca5931b34033fa55c03 (diff) | |
download | epiphany-f849a27760a2e01b38b2c46314f45743eb7a6af3.tar.gz |
Exit early in suggestion model to prevent unnecessary row creation
Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/1096
-rw-r--r-- | src/ephy-suggestion-model.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ephy-suggestion-model.c b/src/ephy-suggestion-model.c index 47cf85e15..162d1f019 100644 --- a/src/ephy-suggestion-model.c +++ b/src/ephy-suggestion-model.c @@ -28,6 +28,7 @@ #include <glib/gi18n.h> #define MAX_COMPLETION_HISTORY_URLS 8 +#define MAX_URL_ENTRIES 25 struct _EphySuggestionModel { GObject parent; @@ -252,7 +253,7 @@ static gboolean append_suggestion (EphySuggestionModel *self, EphySuggestion *suggestion) { - if (self->num_custom_entries < 25) { + if (self->num_custom_entries < MAX_URL_ENTRIES) { g_sequence_append (self->items, suggestion); self->num_custom_entries++; @@ -304,6 +305,8 @@ add_bookmarks (EphySuggestionModel *self, if (append_suggestion (self, suggestion)) { new_urls = g_list_prepend (new_urls, g_strdup (url)); added++; + } else { + break; } } } @@ -344,6 +347,8 @@ add_history (EphySuggestionModel *self, if (append_suggestion (self, suggestion)) added++; + else + break; } return added; @@ -407,7 +412,6 @@ add_tabs (EphySuggestionModel *self, shell = ephy_embed_shell_get_default (); application = G_APPLICATION (shell); windows = gtk_application_get_windows (GTK_APPLICATION (application)); - self->num_custom_entries = 0; for (guint win_idx = 0; win_idx < g_list_length (windows); win_idx++) { window = EPHY_WINDOW (g_list_nth_data (windows, win_idx)); @@ -496,6 +500,7 @@ query_completed_cb (EphyHistoryService *service, self->urls = g_sequence_new (g_free); g_clear_pointer (&self->items, g_sequence_free); self->items = g_sequence_new (g_object_unref); + self->num_custom_entries = 0; if (strlen (query) > 0) { added = add_tabs (self, query); |