From cdb011b40343ecf1fa41352aab3951fe4c8e672a Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 16 Aug 2024 12:14:05 -0700 Subject: [PATCH] libsysprof: use gtk_tim_sort() for counter value sorting This is generally faster than g_array_sort() due to all the heuristics involved, which are likely to hold true for us with counter data. --- src/libsysprof/sysprof-document-counter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libsysprof/sysprof-document-counter.c b/src/libsysprof/sysprof-document-counter.c index 6331cf22..17959ee9 100644 --- a/src/libsysprof/sysprof-document-counter.c +++ b/src/libsysprof/sysprof-document-counter.c @@ -22,6 +22,8 @@ #include +#include "timsort/gtktimsortprivate.h" + #include "sysprof-document-counter-private.h" #include "sysprof-document-counter-value-private.h" #include "sysprof-document-private.h" @@ -358,7 +360,11 @@ _sysprof_document_counter_calculate_range (SysprofDocumentCounter *self) if (self->values->len == 0) return; - g_array_sort (self->values, sort_by_time); + gtk_tim_sort (self->values->data, + self->values->len, + sizeof (SysprofDocumentTimedValue), + (GCompareDataFunc)sort_by_time, + NULL); values = &g_array_index (self->values, SysprofDocumentTimedValue, 0); n_values = self->values->len;