diff --git a/src/compiler/execute.js b/src/compiler/execute.js index 1639fc13..60e03af8 100644 --- a/src/compiler/execute.js +++ b/src/compiler/execute.js @@ -373,19 +373,6 @@ const listGet = (list, idx) => { return list[index]; }; -/** - * listGet() optimized for number arguments. - * @param {Array} list The list - * @param {number} idx The 1-indexed index in the list. - * @returns The list item, otherwise empty string if it does not exist. - */ -const listGetFast = (list, idx) => { - if (idx < 1 || idx > list.length) { - return ''; - } - return list[Math.floor(idx) - 1]; -}; - /** * Replace a value in a list. * @param {import('../engine/variable')} list The list diff --git a/src/compiler/jsgen.js b/src/compiler/jsgen.js index 7dbc5c69..09fb929f 100644 --- a/src/compiler/jsgen.js +++ b/src/compiler/jsgen.js @@ -216,11 +216,8 @@ class JSGenerator { return new TypedInput(`listContents(${this.referenceVariable(node.list)})`, TYPE_STRING); case 'list.get': { const index = this.descendInput(node.index); - if (index.isAlwaysNumber()) { - if (environment.supportsNullishCoalescing) { - return new TypedInput(`(${this.referenceVariable(node.list)}.value[Math.floor(${index.asNumber()}) - 1] ?? "")`, TYPE_UNKNOWN); - } - return new TypedInput(`listGetFast(${this.referenceVariable(node.list)}.value, ${index.asNumber()})`, TYPE_UNKNOWN); + if (environment.supportsNullishCoalescing && index.isAlwaysNumber()) { + return new TypedInput(`(${this.referenceVariable(node.list)}.value[Math.floor(${index.asNumber()}) - 1] ?? "")`, TYPE_UNKNOWN); } return new TypedInput(`listGet(${this.referenceVariable(node.list)}.value, ${index.asUnknown()})`, TYPE_UNKNOWN); }