mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
Remove NextPowerOf2 (for uint64)
This commit is contained in:
parent
1df0854193
commit
091cc215fb
@ -19,21 +19,16 @@ import (
|
||||
"math"
|
||||
)
|
||||
|
||||
func NextPowerOf2(x uint64) uint64 {
|
||||
func NextPowerOf2Int(x int) int {
|
||||
x -= 1
|
||||
x |= (x >> 1)
|
||||
x |= (x >> 2)
|
||||
x |= (x >> 4)
|
||||
x |= (x >> 8)
|
||||
x |= (x >> 16)
|
||||
x |= (x >> 32)
|
||||
return x + 1
|
||||
}
|
||||
|
||||
func NextPowerOf2Int(size int) int {
|
||||
return int(NextPowerOf2(uint64(size)))
|
||||
}
|
||||
|
||||
func RGBA(clr color.Color) (r, g, b, a float64) {
|
||||
cr, cg, cb, ca := clr.RGBA()
|
||||
const max = math.MaxUint16
|
||||
|
@ -21,8 +21,8 @@ import (
|
||||
|
||||
func TestNextPowerOf2(t *testing.T) {
|
||||
testCases := []struct {
|
||||
expected uint64
|
||||
arg uint64
|
||||
expected int
|
||||
arg int
|
||||
}{
|
||||
{256, 255},
|
||||
{256, 256},
|
||||
@ -30,7 +30,7 @@ func TestNextPowerOf2(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
got := NextPowerOf2(testCase.arg)
|
||||
got := NextPowerOf2Int(testCase.arg)
|
||||
wanted := testCase.expected
|
||||
if wanted != got {
|
||||
t.Errorf("Clp(%d) = %d, wanted %d", testCase.arg, got, wanted)
|
||||
|
Loading…
Reference in New Issue
Block a user