Skip to content

@wry/trie idea: speed up lookupArray by avoiding forEach and arrow function allocation #131

@benjamn

Description

@benjamn

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)));
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions