summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-12-29 18:24:38 +0100
committerDan McGee <dan@archlinux.org>2012-01-01 04:03:24 +0100
commit39cb865e71432fbce826d7526b1006be0e036761 (patch)
treeec001cfec042f3de231395c634d3317ff9b45358 /lib
parentb264fb9e9ddcc31dc8782390309421965e507383 (diff)
downloadpacman-39cb865e71432fbce826d7526b1006be0e036761.tar.gz
pacman-39cb865e71432fbce826d7526b1006be0e036761.tar.xz
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/util.c2
1 files changed, 1 insertions, 1 deletions
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;