Thats reaaaly ugly. :) Use `hash = 65599*hash + buf[i];`.