-
Notifications
You must be signed in to change notification settings - Fork 11
refactor(ts-transformers): optimize when/unless based on right-side cost #2195
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
Conversation
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.
No issues found across 10 files
a29c181 to
58fd12d
Compare
| } as const satisfies __ctHelpers.JSONSchema, true as const satisfies __ctHelpers.JSONSchema, { item: { | ||
| name: item.name | ||
| } }, ({ item }) => item.name && <span>{item.name}</span>)} | ||
| } }, ({ item }) => __ctHelpers.when(item.name, <span>{item.name}</span>))} |
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 called from within a derive here? that's a bit redundant taint-wise * uncomplicating jsx. i wonder what triggered that.
58fd12d to
4e16ddb
Compare
4e16ddb to
37becef
Compare
37becef to
060b20b
Compare
060b20b to
4e03a45
Compare
Changes the decision logic for when to use `when`/`unless` helpers: - Previously based on whether LEFT side was a simple opaque ref access - Now based on whether RIGHT side is "expensive" (JSX or needs derive) This better captures the intent: when/unless provide short-circuit optimization that's most valuable when the right side is expensive to construct (like JSX) or when both sides need derive (for taint tracking). Key changes: - Add isJsxExpression() helper to detect JSX elements/fragments - Use when/unless only when: rightIsJsx OR rightNeedsDerive - Simple refs passed directly to when/unless (no derive wrapper) - String/number literals on right side → plain derive, no short-circuit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
3c3fa81 to
070b7b2
Compare
Changes the decision logic for when to use
when/unlesshelpers:This better captures the intent: when/unless provide short-circuit optimization that's most valuable when the right side is expensive to construct (like JSX) or when both sides need derive (for taint tracking).
Key changes:
Summary by cubic
Optimized when/unless usage to only short-circuit when the right-hand side is expensive (JSX or needs derive), reducing unnecessary derive wrapping and matching actual runtime cost.
Written for commit 070b7b2. Summary will update automatically on new commits.