internal/uidriver/js: Optimization: Reduce the call of js.Value.Get

This commit is contained in:
Hajime Hoshi 2021-11-12 02:48:53 +09:00
parent 732b125349
commit b6cf95f5bb

View File

@ -298,7 +298,8 @@ func (i *Input) updateGamepads() {
return
}
if !nav.Get("getGamepads").Truthy() {
gamepads := nav.Call("getGamepads")
if !gamepads.Truthy() {
return
}
@ -306,7 +307,6 @@ func (i *Input) updateGamepads() {
delete(i.gamepads, k)
}
gamepads := nav.Call("getGamepads")
l := gamepads.Length()
for idx := 0; idx < l; idx++ {
gp := gamepads.Index(idx)