Skip to content

Commit 20cb74b

Browse files
committed
perf(uinput): cache spec on device creation
1 parent 5118789 commit 20cb74b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/evdev/uinput.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,21 @@ end
220220
local M = {}
221221

222222
function M.create(spec)
223-
local ui, err = create_uinput(normalize(spec))
223+
spec = normalize(spec)
224+
225+
local ui, err = create_uinput(spec)
224226
if not ui then
225227
return nil, err
226228
end
227-
return setmetatable({ _core = ui }, UInput)
229+
230+
local uinput = { _core = ui }
231+
for k in pairs(defaults) do
232+
if k ~= "path" then
233+
uinput[k] = spec[k]
234+
end
235+
end
236+
237+
return setmetatable(uinput, UInput)
228238
end
229239

230240
---@diagnostic disable-next-line: undefined-global

0 commit comments

Comments
 (0)