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 <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-08-02 09:18:22 -04:00
parent c2178bc265
commit 53285534b9
1 changed files with 7 additions and 2 deletions

View File

@ -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)