From df0551bd5925329b37b0f7d50bcf6e01028014cb Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Wed, 20 Aug 2008 20:03:56 +0200 Subject: [PATCH 15/48] make hal start a lot faster Hal is a significant part of the boot time of (optimized) systems, so optimizing hal to start faster is certainly worthwhile. The patch below cuts the start time of hal by about one third, by reducing the number of calls to hal_device_get_udi() from well over 700.000 to below 100.000. --- hald/device_info.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hald/device_info.c b/hald/device_info.c index 2381612..e378a2e 100644 --- a/hald/device_info.c +++ b/hald/device_info.c @@ -273,22 +273,27 @@ handle_match (struct rule *rule, HalDevice *d) char prop_to_check[HAL_PATH_MAX]; const char *key = rule->key; const char *value = (char *)RULES_PTR(rule->value_offset); + const char *d_udi; + + d_udi = hal_device_get_udi (d); /* Resolve key paths like 'someudi/foo/bar/baz:prop.name' '@prop.here.is.an.udi:with.prop.name' */ if (!resolve_udiprop_path (key, - hal_device_get_udi (d), + d_udi, udi_to_check, sizeof (udi_to_check), prop_to_check, sizeof (prop_to_check))) { /*HAL_ERROR (("Could not resolve keypath '%s' on udi '%s'", key, value));*/ return FALSE; } - d = hal_device_store_find (hald_get_gdl (), udi_to_check); - if (d == NULL) - d = hal_device_store_find (hald_get_tdl (), udi_to_check); - if (d == NULL) { - HAL_ERROR (("Could not find device with udi '%s'", udi_to_check)); - return FALSE; + if (strcmp(udi_to_check, d_udi)) { + d = hal_device_store_find (hald_get_gdl (), udi_to_check); + if (d == NULL) + d = hal_device_store_find (hald_get_tdl (), udi_to_check); + if (d == NULL) { + HAL_ERROR (("Could not find device with udi '%s'", udi_to_check)); + return FALSE; + } } switch (rule->type_match) { -- 1.6.1.2