caching parsed keyboard actions

This commit is contained in:
zadam 2020-10-02 22:29:16 +02:00
parent 620e896a89
commit 90622d71f8

View file

@ -402,7 +402,13 @@ for (const action of DEFAULT_KEYBOARD_ACTIONS) {
} }
} }
let cachedActions = null;
function getKeyboardActions() { function getKeyboardActions() {
if (cachedActions) {
return cachedActions;
}
const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS)); const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
for (const action of actions) { for (const action of actions) {
@ -430,6 +436,8 @@ function getKeyboardActions() {
} }
} }
cachedActions = actions;
return actions; return actions;
} }