[gtk/wip/otte/sortlistmodel: 20/33] sor3listmodel: Do time-based batching



commit 8ae3529bb3216fc5fb099cd1f14e29bc747bd5a1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 11 15:12:17 2020 -0400

    sor3listmodel: Do time-based batching
    
    Stop a sorting step if it has run for more than 1.5ms.
    This is an attempt to improve interactivity during
    incremental sorting.

 gtk/gtksor3listmodel.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtksor3listmodel.c b/gtk/gtksor3listmodel.c
index 6a35619c9d..91193925e0 100644
--- a/gtk/gtksor3listmodel.c
+++ b/gtk/gtksor3listmodel.c
@@ -294,7 +294,7 @@ gtk_sor3_list_model_sort_cb (gpointer data)
 
   start = self->sorted_to;
   n_items = sort_array_get_size (&self->items);
-  end = MIN (512, n_items - start);
+  end = n_items - start;
 
   changed_start = G_MAXUINT;
   changed_end = 0;
@@ -303,6 +303,9 @@ gtk_sor3_list_model_sort_cb (gpointer data)
     {
       iqs (&self->items, self->sorted_to, &self->stack, self->sorter, &changed_start, &changed_end);
       self->sorted_to++;
+
+      if (g_get_monotonic_time () - begin > 1500)
+        break;
     }
 
   if (self->sorted_to >= n_items)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]