From 39cb865e71432fbce826d7526b1006be0e036761 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 29 Dec 2011 11:24:38 -0600 Subject: 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 --- lib/libalpm/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index fc0e0564..2cce8247 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; -- cgit v1.2.3-24-g4f1b