summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>2005-04-01 17:11:55 +0000
committerJoakim Tjernlund <joakim.tjernlund@transmode.se>2005-04-01 17:11:55 +0000
commita55a088d1a39150c8446d23be2f8ab248bf9f644 (patch)
tree9a1c1d584ec13af2dc9326f8ed161e5d0cfe7479
parent0560005b6bb699e195e7334d6908b53db7b2c943 (diff)
Optimize _dl_elf_hash(), both smaller and faster. Mostly
taken from glibc.
-rw-r--r--ldso/ldso/dl-hash.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c
index 863f8fb6e..5de38a61e 100644
--- a/ldso/ldso/dl-hash.c
+++ b/ldso/ldso/dl-hash.c
@@ -59,14 +59,20 @@ struct dyn_elf *_dl_handles = NULL;
* it to decode the hash table. */
static inline unsigned long _dl_elf_hash(const unsigned char *name)
{
- unsigned long hash = 0;
+ unsigned long hash=0;
unsigned long tmp;
while (*name) {
hash = (hash << 4) + *name++;
- if ((tmp = hash & 0xf0000000))
- hash ^= tmp >> 24;
- hash &= ~tmp;
+ tmp = hash & 0xf0000000;
+ /* The algorithm specified in the ELF ABI is as follows:
+ if (tmp != 0)
+ hash ^= tmp >> 24;
+ hash &= ~tmp;
+ But the following is equivalent and a lot
+ faster, especially on modern processors. */
+ hash ^= tmp;
+ hash ^= tmp >> 24;
}
return hash;
}