mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-09-20 05:12:18 +02:00
audio/internal/convert: refactoring
This commit is contained in:
parent
3b7bc2fc57
commit
1906262ef4
@ -28,7 +28,7 @@ var (
|
|||||||
cosTableOnce sync.Once
|
cosTableOnce sync.Once
|
||||||
)
|
)
|
||||||
|
|
||||||
func getCosTable() []float64 {
|
func ensureCosTable() []float64 {
|
||||||
cosTableOnce.Do(func() {
|
cosTableOnce.Do(func() {
|
||||||
cosTable = make([]float64, 65536)
|
cosTable = make([]float64, 65536)
|
||||||
for i := range cosTable {
|
for i := range cosTable {
|
||||||
@ -42,7 +42,9 @@ func fastCos01(x float64) float64 {
|
|||||||
if x < 0 {
|
if x < 0 {
|
||||||
x = -x
|
x = -x
|
||||||
}
|
}
|
||||||
i := int(4 * float64(len(getCosTable())) * x)
|
|
||||||
|
cosTable := ensureCosTable()
|
||||||
|
i := int(4 * float64(len(cosTable)) * x)
|
||||||
if 4*len(cosTable) < i {
|
if 4*len(cosTable) < i {
|
||||||
i %= 4 * len(cosTable)
|
i %= 4 * len(cosTable)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user