benjamn / benjamn/wryware

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

Open
#131 0 comments 0 reactions 1 assignee Claimed by @benjamn View on GitHub
@wry/trie enhancement
Dominant language
TypeScript
Stars
91
Forks
15
PR merge metrics
No merged PRs in 30d

Description

In code that relies heavily on the `Trie` data structure provided by `@wry/trie`, [this code](https://github.com/benjamn/wryware/blob/27a83c25c8dd913daf8c6fd3f450ab6cc1ba0111/packages/trie/src/trie.ts#L29-L33) has the potential to be hot, and thus worth optimizing for speed, even if that means rewriting it in a different style:
```ts
public lookupArray(array: T): Data {
let node: Trie = this;
forEach.call(array, key => node = node.getChildTrie(key));
return node.data || (node.data = this.makeData(slice.call(array)));
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.