diff --git a/http.go b/http.go index 5e3d7d3694..feb63f7f91 100644 --- a/http.go +++ b/http.go @@ -1956,11 +1956,13 @@ func round2(n int) int { if n <= 0 { return 0 } - n-- - x := uint(0) - for n > 0 { - n >>= 1 - x++ - } - return 1 << x + + x := uint32(n - 1) + x |= x >> 1 + x |= x >> 2 + x |= x >> 4 + x |= x >> 8 + x |= x >> 16 + + return int(x + 1) }