FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 01-01-2012, 02:07 AM
Dan McGee
 
Default Simplify hash function to a single multiplication

More than likely the compiler will do the three operation breakdown we
had here before (2 shifts + subtraction), but let the compiler do the
optimizations and make the actual operation more obvious. This actually
slightly shrinks the function binary size, likely due to instruction
reordering or something.

Signed-off-by: Dan McGee <dan@archlinux.org>
---

2^6 + 2^16 - 1

lib/libalpm/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index fc0e056..2cce824 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -1145,7 +1145,7 @@ unsigned long _alpm_hash_sdbm(const char *str)
return hash;
}
while((c = *str++)) {
- hash = c + (hash << 6) + (hash << 16) - hash;
+ hash = c + hash * 65599;
}

return hash;
--
1.7.8.1
 

Thread Tools




All times are GMT. The time now is 05:02 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org