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

Add support for acceptsUndefined: false to safe references #109

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

airhorns
Copy link
Contributor

MST proper supports an acceptsUndefined: false on safe references that automatically prunes invalid references from parent maps and arrays. I wanna use it in Gadget but noticed that it no worky -- we pass the option through to observable instances fine but didn't do anything with it in readonly instances. This adds handling for the special case, which requires arrays and maps to look at the child type, and if it is a safe reference with the option set, omit unresolved entries from the result. Woop woop.

@airhorns airhorns marked this pull request as ready for review October 17, 2024 14:58
@airhorns airhorns requested a review from thegedge October 17, 2024 14:58
Copy link

codspeed-hq bot commented Oct 17, 2024

CodSpeed Performance Report

Merging #109 will improve performances by 75.22%

Comparing accepts-undefined (5488410) with accepts-undefined (330abed)

Summary

⚡ 1 improvements
✅ 10 untouched benchmarks

Benchmarks breakdown

Benchmark accepts-undefined accepts-undefined Change
instantiating a large union 101.6 µs 58 µs +75.22%

Copy link
Contributor

@thegedge thegedge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

src/map.ts Outdated Show resolved Hide resolved
src/fast-instantiator.ts Outdated Show resolved Hide resolved
src/array.ts Outdated Show resolved Hide resolved
MST proper supports an `acceptsUndefined: false` on safe references that automatically prunes invalid references from parent maps and arrays. I wanna use it in Gadget but noticed that it no worky -- we pass the option through to observable instances fine but didn't do anything with it in readonly instances. This adds handling for the special case, which requires arrays and maps to look at the child type, and if it is a safe reference with the option set, omit unresolved entries from the result. Woop woop.
@airhorns airhorns merged commit c59b402 into main Oct 17, 2024
6 checks passed
@airhorns airhorns deleted the accepts-undefined branch October 17, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants