Skip to content

[th/gdataset-index] add a lookup index (GHashTable) to `GData`

Thomas Haller requested to merge th/gdataset-index into main

GData is heavily used, for example for attaching user data to GObject.

It uses a linear buffer and linear search to track the entries. That works great if there are few entries, but performs badly with many entries.

Add an GHashTable lookup index after the GData grows to a certain size.

The main point here is that GData should always(*) work reasonably well, and you don't need to worry that the performance starts to degrade. Especially, when it would be hard to clearly quantify how many are too many.

The second point is that GObject uses GData for internal purposes, so it's important that lookup is fast and locks are held for a short time.

(*) "always", up to a certain point. Even with this patch adding more than 10k entries is gonna be a problem simply because this is a thread-safe container.

Edited by Thomas Haller

Merge request reports