context: hash the globals by id

Store the globals by id in a hashtable. O(1) insert and remove.
It moves the find_global overhead from the top of the list to somewhere
in the middle for the jack-stress test.
This commit is contained in:
Wim Taymans 2022-01-14 13:19:31 +01:00
parent 6394537dbd
commit 80b2e345d7
2 changed files with 13 additions and 2 deletions

View file

@ -321,6 +321,7 @@ struct pw_global {
struct spa_list link; /**< link in context list of globals */
struct spa_list sorted_link; /**< link in context list of sorted_globals */
struct spa_list map_link; /**< link in context list of global_map */
uint32_t id; /**< server id of the object */
struct pw_properties *properties; /**< properties of the global */
@ -452,6 +453,8 @@ struct pw_context {
struct pw_array factory_lib; /**< mapping of factory_name regexp to library */
uint32_t serial;
#define GLOBAL_HASH_SIZE 127
struct spa_list global_map[GLOBAL_HASH_SIZE];
struct spa_list sorted_globals;
struct pw_array objects; /**< objects */