mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02:02 +01:00
devicescale: Cache scale values
This commit is contained in:
parent
a3882dbc37
commit
1392129e41
@ -18,12 +18,22 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type pos struct {
|
||||
x, y int
|
||||
}
|
||||
|
||||
var (
|
||||
m sync.Mutex
|
||||
m sync.Mutex
|
||||
cache = map[pos]float64{}
|
||||
)
|
||||
|
||||
func GetAt(x, y int) float64 {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
return impl(x, y)
|
||||
if s, ok := cache[pos{x, y}]; ok {
|
||||
return s
|
||||
}
|
||||
s := impl(x, y)
|
||||
cache[pos{x, y}] = s
|
||||
return s
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user