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.
This commit is contained in:
Christian Hergert
2024-08-16 12:14:05 -07:00
parent d67adc598b
commit cdb011b403

View File

@ -22,6 +22,8 @@
#include <math.h>
#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;