libsysprof: port GPtrArray sort to gtk_tim_sort()

This commit is contained in:
Christian Hergert
2024-08-16 12:50:21 -07:00
parent b06c08c64e
commit 54295a1466
3 changed files with 22 additions and 3 deletions

View File

@ -20,7 +20,10 @@
#include "config.h"
#include "timsort/gtktimsortprivate.h"
#include <gio/gio.h>
#include <eggbitset.h>
#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))

View File

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

View File

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