@wry/trie idea: speed up lookupArray by avoiding forEach and arrow function allocation
benjamn opened this issue · comments
Ben Newman commented
In code that relies heavily on the Trie
data structure provided by @wry/trie
, this code has the potential to be hot, and thus worth optimizing for speed, even if that means rewriting it in a different style:
public lookupArray<T extends IArguments | any[]>(array: T): Data {
let node: Trie<Data> = this;
forEach.call(array, key => node = node.getChildTrie(key));
return node.data || (node.data = this.makeData(slice.call(array)));
}