From 54295a146603ba68572d11d6473d611fd6ce1efb Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 16 Aug 2024 12:50:21 -0700 Subject: [PATCH] libsysprof: port GPtrArray sort to gtk_tim_sort() --- src/libsysprof/sysprof-address-layout.c | 9 ++++++++- src/libsysprof/sysprof-callgraph.c | 8 +++++++- src/libsysprof/sysprof-mount-namespace.c | 8 +++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/libsysprof/sysprof-address-layout.c b/src/libsysprof/sysprof-address-layout.c index ff92fe26..91675485 100644 --- a/src/libsysprof/sysprof-address-layout.c +++ b/src/libsysprof/sysprof-address-layout.c @@ -20,7 +20,10 @@ #include "config.h" +#include "timsort/gtktimsortprivate.h" + #include + #include #include "sysprof-address-layout-private.h" @@ -204,7 +207,11 @@ sysprof_address_layout_lookup (SysprofAddressLayout *self, self->mmaps_dirty = FALSE; - g_ptr_array_sort (self->mmaps, compare_mmaps); + gtk_tim_sort (self->mmaps->pdata, + self->mmaps->len, + sizeof (gpointer), + (GCompareDataFunc)compare_mmaps, + NULL); dups = find_duplicates (self->mmaps); if (egg_bitset_iter_init_last (&iter, dups, &i)) diff --git a/src/libsysprof/sysprof-callgraph.c b/src/libsysprof/sysprof-callgraph.c index 2ee53a74..c91ba900 100644 --- a/src/libsysprof/sysprof-callgraph.c +++ b/src/libsysprof/sysprof-callgraph.c @@ -20,6 +20,8 @@ #include "config.h" +#include "timsort/gtktimsortprivate.h" + #include "sysprof-callgraph-private.h" #include "sysprof-callgraph-frame-private.h" #include "sysprof-callgraph-symbol-private.h" @@ -990,7 +992,11 @@ sysprof_callgraph_list_traceables_for_node_async (SysprofCallgraph *self, } /* Sort the bitsets by size to shrink potential interscetions */ - g_ptr_array_sort (bitsets, sort_by_size_asc); + gtk_tim_sort (bitsets->pdata, + bitsets->len, + sizeof (gpointer), + (GCompareDataFunc)sort_by_size_asc, + NULL); bitset = egg_bitset_copy (g_ptr_array_index (bitsets, 0)); for (guint i = 1; i < bitsets->len; i++) { diff --git a/src/libsysprof/sysprof-mount-namespace.c b/src/libsysprof/sysprof-mount-namespace.c index a207e9f8..43d3f52f 100644 --- a/src/libsysprof/sysprof-mount-namespace.c +++ b/src/libsysprof/sysprof-mount-namespace.c @@ -22,6 +22,8 @@ #include +#include "timsort/gtktimsortprivate.h" + #include "sysprof-mount-namespace-private.h" struct _SysprofMountNamespace @@ -249,7 +251,11 @@ sysprof_mount_namespace_translate (SysprofMountNamespace *self, if G_UNLIKELY (self->mounts_dirty) { - g_ptr_array_sort (self->mounts, compare_mount); + gtk_tim_sort (self->mounts->pdata, + self->mounts->len, + sizeof (gpointer), + (GCompareDataFunc)compare_mount, + NULL); self->mounts_dirty = FALSE; }