`hash += 32*hash + buf[i];`, optimizing the multiplication is should be done by the compiler, not in the code.