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