-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add memoization to Cache
#1720
base: main
Are you sure you want to change the base?
Add memoization to Cache
#1720
Conversation
🦋 Changeset detectedLatest commit: 83540d1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 77 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
const hasHiddenAncestors = Cache.memoize< | ||
unknown, | ||
[Device, Context], | ||
Predicate<Node> | ||
>(_hasHiddenAncestors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why TS needs some skaffolding here, but not in the simple cases in the tests 🤷
const cache = Cache.empty<Device, Cache<Context, Cache<Node, boolean>>>(); | ||
|
||
function hasHiddenAncestors( | ||
function _hasHiddenAncestors( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a demo of using the new decorator, not directly related to the changes.
), | ||
// Or its parent is programmatically hidden | ||
(node: Node) => | ||
node.parent(Node.fullTree).some(_hasHiddenAncestors(device, context)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Is it on purpose the call is to _hasHiddenAncestors
and not hasHiddenAncestors
? I can't tell if it makes a difference, but in the original code, in the recursion the cache would be used, but now it's going to recurse without the cache, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. Good point. 🤔
No description provided.