mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
uidriver/mobile: Prefer sync.Once to sync.Mutex
This commit is contained in:
parent
d7aa24c295
commit
2c23860226
@ -105,17 +105,14 @@ type UserInterface struct {
|
||||
}
|
||||
|
||||
var (
|
||||
deviceScaleVal float64
|
||||
deviceScaleM sync.Mutex
|
||||
deviceScaleVal float64
|
||||
deviceScaleOnce sync.Once
|
||||
)
|
||||
|
||||
func getDeviceScale() float64 {
|
||||
deviceScaleM.Lock()
|
||||
defer deviceScaleM.Unlock()
|
||||
|
||||
if deviceScaleVal == 0 {
|
||||
deviceScaleOnce.Do(func() {
|
||||
deviceScaleVal = devicescale.GetAt(0, 0)
|
||||
}
|
||||
})
|
||||
return deviceScaleVal
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user