From 10e5e9e633972962cd9d62a0245003721250fb38 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 25 Jan 2021 22:47:44 +0900 Subject: [PATCH] internal/uidriver: Prepare the slice capacities --- internal/uidriver/glfw/input.go | 2 +- internal/uidriver/js/input_js.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/uidriver/glfw/input.go b/internal/uidriver/glfw/input.go index 5a2bfa0ca..65d18acf3 100644 --- a/internal/uidriver/glfw/input.go +++ b/internal/uidriver/glfw/input.go @@ -70,9 +70,9 @@ func (i *Input) GamepadIDs() []driver.GamepadID { return nil } - var r []driver.GamepadID i.ui.m.RLock() defer i.ui.m.RUnlock() + r := make([]driver.GamepadID, 0, len(i.gamepads)) for id, g := range i.gamepads { if g.valid { r = append(r, driver.GamepadID(id)) diff --git a/internal/uidriver/js/input_js.go b/internal/uidriver/js/input_js.go index 5bc7d589e..a295c1226 100644 --- a/internal/uidriver/js/input_js.go +++ b/internal/uidriver/js/input_js.go @@ -113,7 +113,7 @@ func (i *Input) GamepadIDs() []driver.GamepadID { return nil } - var r []driver.GamepadID + r := make([]driver.GamepadID, 0, i.gamepads) for id := range i.gamepads { r = append(r, id) }