mirror of
https://github.com/mirror/make.git
synced 2026-08-09 09:32:12 +00:00
hash: Remove unnecessary isupper() check before tolower()
The standard requires that tolower() returns its argument if there's no valid lowercase conversion: it's not necessary to check isupper() before invoking tolower(). Comparing the performance of the old ISTRING_HASH to the new one on all the files present in GLIBC. Data Type Old Time New Time Alternating case 24985.754 13883.422 random case 35211.777 13569.051 all lower 18818.974 13706.645 all upper 38859.454 13506.315 * src/hash.h (ISTRING_HASH_1): Omit isupper() check. (ISTRING_HASH_2): Ditto.
This commit is contained in:
committed by
Paul Smith
parent
668eda0527
commit
9fa63eb918
@@ -56,9 +56,9 @@ struct hash_table
|
||||
typedef int (*qsort_cmp_t) __P((void const *, void const *));
|
||||
|
||||
void hash_init __P((struct hash_table *ht, unsigned long size,
|
||||
hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp));
|
||||
hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp));
|
||||
void hash_load __P((struct hash_table *ht, void *item_table,
|
||||
unsigned long cardinality, unsigned long size));
|
||||
unsigned long cardinality, unsigned long size));
|
||||
void **hash_find_slot __P((struct hash_table *ht, void const *key));
|
||||
void *hash_find_item __P((struct hash_table *ht, void const *key));
|
||||
void *hash_insert __P((struct hash_table *ht, const void *item));
|
||||
@@ -154,7 +154,7 @@ extern void *hash_deleted_item;
|
||||
#define ISTRING_HASH_1(KEY, RESULT) do { \
|
||||
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
|
||||
while (*++_key_) \
|
||||
(RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0xf)); \
|
||||
(RESULT) += (tolower (*_key_) << (_key_[1] & 0xf)); \
|
||||
} while (0)
|
||||
#define return_ISTRING_HASH_1(KEY) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
@@ -165,7 +165,7 @@ extern void *hash_deleted_item;
|
||||
#define ISTRING_HASH_2(KEY, RESULT) do { \
|
||||
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
|
||||
while (*++_key_) \
|
||||
(RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0x7)); \
|
||||
(RESULT) += (tolower (*_key_) << (_key_[1] & 0x7)); \
|
||||
} while (0)
|
||||
#define return_ISTRING_HASH_2(KEY) do { \
|
||||
unsigned long _result_ = 0; \
|
||||
|
||||
Reference in New Issue
Block a user