It turns out that sys/hash.h also uses Chris Toreks hash algorithm in the same 1:1 way that was present in Berkeley DB a decade ago. So maybe "i prefer leaving optimization up to the compiler" should be applied here, too. The patch does this.
And - you know, i never made it into that gcc(1) code jungle, but maybe someone with experience simply needs to toggle a switch for better behaviour - the following seems strange to me: #include <stdio.h> int main(void) { int i = 3; printf("i = %d\n", i); #ifdef T1 for (int x = 1; x < i; ++x) #else int x = 1; #endif printf("x = %d\n", x); return 0; } ?0%1[steffen@obsd tmp]$ /usr/bin/gcc -W -Wall -pedantic -o t -c t.c t.c: In function 'main': t.c:9: warning: ISO C90 forbids mixed declarations and code ?0%1[steffen@obsd tmp]$ /usr/bin/gcc -DT1 -W -Wall -pedantic -o t -c t.c t.c: In function 'main': t.c:7: error: 'for' loop initial declaration used outside C99 mode ?1%1[steffen@obsd tmp]$ E.g., clang(1) does this (also for -std=c90): ?0%0[steffen@sherwood tmp]$ clang -DT1 -W -Wall -pedantic -ansi -o t -c t.c t.c:7:14: warning: variable declaration in for loop is a C99-specific feature [-pedantic] for (int x = 1; x < i; ++x) ^ 1 warning generated. ?0%0[steffen@sherwood tmp]$ clang -W -Wall -pedantic -ansi -o t -c t.c t.c:9:13: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement] int x = 1; ^ 1 warning generated. ?0%0[steffen@sherwood tmp]$ --steffen Index: sys/sys/hash.h =================================================================== RCS file: /Users/steffen/arena/code.openbsd/src/sys/sys/hash.h,v retrieving revision 1.5 diff -a -p -u -r1.5 hash.h --- sys/sys/hash.h 24 Sep 2010 13:24:53 -0000 1.5 +++ sys/sys/hash.h 14 Feb 2012 17:05:43 -0000 @@ -40,7 +40,7 @@ /* Convenience */ #ifndef HASHINIT #define HASHINIT 5381 -#define HASHSTEP(x,c) (((x << 5) + x) + (c)) +#define HASHSTEP(x,c) ((x)*33 + (c)) #endif /*