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>
This commit is contained in:
parent
b264fb9e9d
commit
39cb865e71
1 changed files with 1 additions and 1 deletions
|
@ -1145,7 +1145,7 @@ unsigned long _alpm_hash_sdbm(const char *str)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
while((c = *str++)) {
|
while((c = *str++)) {
|
||||||
hash = c + (hash << 6) + (hash << 16) - hash;
|
hash = c + hash * 65599;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
|
|
Loading…
Add table
Reference in a new issue