refactor(core): simpler after-timer dispatch, fewer per-event allocations - #71
Merged
Conversation
- `after` timers dispatch through `enqueue` like any send; the private flush cycle and the unreachable microtask branch in `dispatchAfter` are gone, and the stale check keeps only the entry generation - `send` / `setContext` are class-field arrows; `doSend` and the `notify` wrapper are removed; the action host gets the bound fields directly - one frozen `INIT_EVENT` instead of a fresh boot event per use - `oneOf` picks its branch with a loop instead of `find` Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- runActions / resolve run a single entry directly, no one-item array wrap - resolve builds guard params lazily and takes the action host, so the per-event resolver closure and selectTransition fast path are gone - action host and computed host hold the live ctx/computed objects; no getter call per read (computed proxy reads and stale() checks included) - connector builds the connect() argument once; shallowEqual compares props with two for..in passes, no key arrays Single event +7%, state churn +10%, guard fallthrough unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
`flushing` was the only "flush"; the method, the dev limit, the error text and the spec all said "drain". Align on flush: `flushQueue`, `MAX_FLUSH`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Column padding was left over from the dropped POLA row (#69); oxfmt --check failed on main because of it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why/What
A review pass over the core machine for simpler code and hot-path allocations. Two commits, each with a patch changeset. No behavior change for consumers.
Changes
KISS (
af725ef)aftertimers dispatch throughenqueuelike any send.dispatchAfterno longer runs its own copy of the flush cycle, and thequeueMicrotaskbranch is gone (a timer cannot fire inside a synchronous drain). The stale check keeps only the entry generation, which already covers "state exited" and "state re-entered".sendandsetContextare class-field arrows likestartandstop.doSendand thenotifywrapper are removed.INIT_EVENTinstead of a fresh boot event per use.oneOfpicks its branch with a loop instead offind.Perf (
6aa4c3f)runActionsandresolverun a single entry directly, no one-item array wrap per event.resolveowns all three entry forms and builds guard params only when a guard is met. The per-event resolver closure and theselectTransitionfast path in the machine are gone.ctxandcomputedobjects. No getter call per read, including inside the computed tracking proxies andstale().connect()argument once.shallowEqualcompares props with twofor..inpasses instead of twoObject.keysarrays.Same-session A/B against the KISS commit:
Full suite, typecheck, lint and format pass. Documented benchmark tables are unchanged: the headline rows moved within noise.
Open point for review: the
shallowEqualrewrite inconnector.tsis the one change that adds a little subtlety (key counter) without a measured gain. Happy to drop it back toObject.keysif you prefer.Issues
None.
🤖 Generated with Claude Code