2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-03 15:55:15 +00:00

Speed up sensors_get_ignored() a bit. We can return as soon as an ignore

statement is found to match, even if it isn't an exact match.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4642 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2007-07-22 12:51:57 +00:00
parent 462e7d81df
commit a62ee5bac2
2 changed files with 8 additions and 10 deletions

View File

@@ -16,6 +16,7 @@ SVN HEAD
Delete all remnants of algorithm names Delete all remnants of algorithm names
Drop all the chip-specific support Drop all the chip-specific support
Fix a memory leak on error Fix a memory leak on error
Speed up sensors_get_ignored() a bit
Makefile: Drop the package and version targets Makefile: Drop the package and version targets
Man page sensors.conf.5: Update the chip statement section Man page sensors.conf.5: Update the chip statement section
Programs doc/*: Delete, obsolete Programs doc/*: Delete, obsolete

View File

@@ -198,10 +198,8 @@ int sensors_get_ignored(sensors_chip_name name, int feature)
const sensors_chip *chip; const sensors_chip *chip;
const sensors_chip_feature *featureptr; const sensors_chip_feature *featureptr;
const sensors_chip_feature *alt_featureptr; const sensors_chip_feature *alt_featureptr;
int i, res; int i;
/* Default: valid */
res = 1;
if (sensors_chip_name_has_wildcards(name)) if (sensors_chip_name_has_wildcards(name))
return -SENSORS_ERR_WILDCARDS; return -SENSORS_ERR_WILDCARDS;
if (!(featureptr = sensors_lookup_feature_nr(&name, feature))) if (!(featureptr = sensors_lookup_feature_nr(&name, feature)))
@@ -214,13 +212,12 @@ int sensors_get_ignored(sensors_chip_name name, int feature)
return -SENSORS_ERR_NO_ENTRY; return -SENSORS_ERR_NO_ENTRY;
for (chip = NULL; (chip = sensors_for_all_config_chips(name, chip));) for (chip = NULL; (chip = sensors_for_all_config_chips(name, chip));)
for (i = 0; i < chip->ignores_count; i++) for (i = 0; i < chip->ignores_count; i++)
if (!strcasecmp(featureptr->data.name, chip->ignores[i].name)) if (!strcasecmp(featureptr->data.name, chip->ignores[i].name) ||
return 0; /* Exact match always overrules! */ (alt_featureptr &&
else if (alt_featureptr && !strcasecmp(alt_featureptr->data.name, chip->ignores[i].name)))
!strcasecmp(alt_featureptr->data.name, return 0;
chip->ignores[i].name)) /* valid */
res = 0; return 1;
return res;
} }
/* Read the value of a feature of a certain chip. Note that chip should not /* Read the value of a feature of a certain chip. Note that chip should not