diff --git a/lang/types/util.go b/lang/types/util.go index 24140fdc..225f1506 100644 --- a/lang/types/util.go +++ b/lang/types/util.go @@ -23,13 +23,14 @@ import ( ) // nextPowerOfTwo gets the lowest number higher than v that is a power of two. -func nextPowerOfTwo(v uint32) uint32 { +func nextPowerOfTwo(v uint) uint { v-- v |= v >> 1 v |= v >> 2 v |= v >> 4 v |= v >> 8 v |= v >> 16 + v |= v >> 32 v++ return v } diff --git a/lang/types/util_test.go b/lang/types/util_test.go index 152051f4..7e64c3c5 100644 --- a/lang/types/util_test.go +++ b/lang/types/util_test.go @@ -20,7 +20,7 @@ package types import "testing" func TestNextPowerOfTwo(t *testing.T) { - testCases := map[uint32]uint32{ + testCases := map[uint]uint{ 1: 1, 2: 2, 3: 4, diff --git a/lang/types/value.go b/lang/types/value.go index a2077118..4dc7c958 100644 --- a/lang/types/value.go +++ b/lang/types/value.go @@ -333,7 +333,7 @@ func Into(v Value, rv reflect.Value) error { switch kind { case reflect.Slice: - pow := nextPowerOfTwo(uint32(count)) + pow := nextPowerOfTwo(uint(count)) nval := reflect.MakeSlice(rv.Type(), count, int(pow)) rv.Set(nval)