From 53285534b9b1cc1b3e13da44bbc6812cc77f8ba6 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 2 Aug 2016 09:18:22 -0400 Subject: [PATCH] gui/model: Improve the efficiency of gui_queue_model_clear() We can cut out several thousand function calls and allocations by reusing the same GtkTreePath structure. Signed-off-by: Anna Schumaker --- gui/model.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gui/model.c b/gui/model.c index 8c6896c8..c68fb087 100644 --- a/gui/model.c +++ b/gui/model.c @@ -278,10 +278,15 @@ void gui_queue_model_remove(GuiQueueModel *model, unsigned int row) void gui_queue_model_clear(GuiQueueModel *model, unsigned int n) { + GtkTreePath *path = gtk_tree_path_new_from_indices(n - 1, -1); unsigned int i; - for (i = 1; i <= n; i++) - gui_queue_model_remove(model, n - i); + for (i = 0; i < n; i++) { + gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), path); + gtk_tree_path_prev(path); + } + + gtk_tree_path_free(path); } void gui_queue_model_update(GuiQueueModel *model, unsigned int row)