Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
benjamn opened this issue Apr 17, 2021 · 0 comments · May be fixed by #138
Open

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

benjamn opened this issue Apr 17, 2021 · 0 comments · May be fixed by #138
Assignees
Labels
enhancement New feature or request @wry/trie

Comments

@benjamn
Copy link
Owner

benjamn commented Apr 17, 2021

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)));
}
@benjamn benjamn added enhancement New feature or request @wry/trie labels Apr 17, 2021
@benjamn benjamn self-assigned this Apr 17, 2021
@benjamn benjamn linked a pull request May 11, 2021 that will close this issue
@benjamn benjamn linked a pull request May 11, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request @wry/trie
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant