This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, master, updated. glibc-2.14-547-g52ad36a
- From: drepper at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 4 Dec 2011 22:44:50 -0000
- Subject: GNU C Library master sources branch, master, updated. glibc-2.14-547-g52ad36a
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 52ad36a21973c0b4fbc16b7104bbffec765e5a23 (commit)
from 52ff5dd0e4ad6436def42b58bc8abe5b534cf739 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=52ad36a21973c0b4fbc16b7104bbffec765e5a23
commit 52ad36a21973c0b4fbc16b7104bbffec765e5a23
Author: Ulrich Drepper <drepper@gmail.com>
Date: Sun Dec 4 17:44:33 2011 -0500
Small optimization of generic ELF hash function
diff --git a/ChangeLog b/ChangeLog
index 0dfff5c..f4b3460 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
2011-12-04 Ulrich Drepper <drepper@gmail.com>
* sysdeps/generic/dl-hash.h (_dl_elf_hash): Fix attribute.
+ Minor optimizations.
* sunrpc/clnt_unix.c (clntunix_control): Fix aliasing issues.
* sunrpc/clnt_tcp.c (clnttcp_control): Likewise.
diff --git a/sysdeps/generic/dl-hash.h b/sysdeps/generic/dl-hash.h
index e35bd25..28312ca 100644
--- a/sysdeps/generic/dl-hash.h
+++ b/sysdeps/generic/dl-hash.h
@@ -29,42 +29,39 @@ __attribute__ ((unused))
_dl_elf_hash (const char *name_arg)
{
const unsigned char *name = (const unsigned char *) name_arg;
- unsigned long int hash = 0;
- if (*name != '\0')
+ unsigned long int hash = *name;
+ if (hash != 0 && name[1] != '\0')
{
- hash = *name++;
- if (*name != '\0')
+ hash = (hash << 4) + name[1];
+ if (name[2] != '\0')
{
- hash = (hash << 4) + *name++;
- if (*name != '\0')
+ hash = (hash << 4) + name[2];
+ if (name[3] != '\0')
{
- hash = (hash << 4) + *name++;
- if (*name != '\0')
+ hash = (hash << 4) + name[3];
+ if (name[4] != '\0')
{
- hash = (hash << 4) + *name++;
- if (*name != '\0')
+ hash = (hash << 4) + name[4];
+ name += 5;
+ while (*name != '\0')
{
+ unsigned long int hi;
hash = (hash << 4) + *name++;
- while (*name != '\0')
- {
- unsigned long int hi;
- hash = (hash << 4) + *name++;
- hi = hash & 0xf0000000;
+ hi = hash & 0xf0000000;
- /* The algorithm specified in the ELF ABI is as
- follows:
+ /* The algorithm specified in the ELF ABI is as
+ follows:
- if (hi != 0)
- hash ^= hi >> 24;
+ if (hi != 0)
+ hash ^= hi >> 24;
- hash &= ~hi;
+ hash &= ~hi;
- But the following is equivalent and a lot
- faster, especially on modern processors. */
+ But the following is equivalent and a lot
+ faster, especially on modern processors. */
- hash ^= hi;
- hash ^= hi >> 24;
- }
+ hash ^= hi;
+ hash ^= hi >> 24;
}
}
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 1 +
sysdeps/generic/dl-hash.h | 47 +++++++++++++++++++++-----------------------
2 files changed, 23 insertions(+), 25 deletions(-)
hooks/post-receive
--
GNU C Library master sources