internal/uidriver: Prepare the slice capacities

This commit is contained in:
Hajime Hoshi 2021-01-25 22:47:44 +09:00
parent 68411e9591
commit 10e5e9e633
2 changed files with 2 additions and 2 deletions

View File

@ -70,9 +70,9 @@ func (i *Input) GamepadIDs() []driver.GamepadID {
return nil return nil
} }
var r []driver.GamepadID
i.ui.m.RLock() i.ui.m.RLock()
defer i.ui.m.RUnlock() defer i.ui.m.RUnlock()
r := make([]driver.GamepadID, 0, len(i.gamepads))
for id, g := range i.gamepads { for id, g := range i.gamepads {
if g.valid { if g.valid {
r = append(r, driver.GamepadID(id)) r = append(r, driver.GamepadID(id))

View File

@ -113,7 +113,7 @@ func (i *Input) GamepadIDs() []driver.GamepadID {
return nil return nil
} }
var r []driver.GamepadID r := make([]driver.GamepadID, 0, i.gamepads)
for id := range i.gamepads { for id := range i.gamepads {
r = append(r, id) r = append(r, id)
} }