[PATCH][RFC]Use a hash table for device properties.
David Zeuthen
david at fubar.dk
Tue Aug 30 08:39:04 PDT 2005
On Thu, 2005-08-25 at 17:01 +0200, Cornelia Huck wrote:
> This patch converts the list of properties maintained in HalDevice to a
> GHashTable. It manages to get a few seconds off the start time on my system
> (about 1:30 min); I guess more savings could be made by implementing a
> generic device hash table (I'll look at that next).
>
> While this implementation works for me, please test and review carefully :)
OK, so I tried this one out.. and it looks pretty good I think. It also
seems to work for me. I'd appreciate if others can test and/or review
this as well
Some comments inline:
> +static gboolean
> +hal_hash_property_free (gpointer key, gpointer value, gpointer user_data)
> +{
> + return TRUE;
> +}
> +
> + g_hash_table_foreach_remove (device->property_hash,
> + hal_hash_property_free, NULL);
Maybe we don't need the hal_hash_property_free function if it's empty?
> +static void
> hal_device_init (HalDevice *device)
> {
> static int temp_device_counter = 0;
>
> device->udi = g_strdup_printf ("/org/freedesktop/Hal/devices/temp/%d",
> temp_device_counter++);
> +
> + device->property_hash =
> + g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
> + hal_device_property_destroy);
So.. aren't we leaking the property name (hashtable key) here?
> {
> - GSList *iter;
> - size_t source_ns_len;
> -
> - source_ns_len = strlen (source_namespace);
> + struct hal_device_merge_with_rewrite_data data = {
> + .target = target,
> + .target_namespace = target_namespace,
> + .source_namespace = source_namespace,
> + };
We should probably avoid using C99 constructs in the shared code (ok in
hald/linux2 though)..
Thanks,
David
More information about the hal
mailing list