graphics: Speed optimization at maxf32 and minf32

This commit is contained in:
Hajime Hoshi 2019-09-29 00:55:24 +09:00
parent 5e6bdc25e5
commit df9458510d

View File

@ -372,22 +372,30 @@ func pow2(power int) float32 {
return x return x
} }
func maxf32(values ...float32) float32 { func maxf32(a, b, c, d float32) float32 {
max := float32(math.Inf(-1)) max := a
for _, v := range values { if max < b {
if max < v { max = b
max = v }
} if max < c {
max = c
}
if max < d {
max = d
} }
return max return max
} }
func minf32(values ...float32) float32 { func minf32(a, b, c, d float32) float32 {
min := float32(math.Inf(1)) min := a
for _, v := range values { if min > b {
if min > v { min = b
min = v }
} if min > c {
min = c
}
if min > d {
min = d
} }
return min return min
} }