refactor(internals): reduce flushPending overhead (performance)#3285
refactor(internals): reduce flushPending overhead (performance)#3285dmaskasky wants to merge 1 commit intopmndrs:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
FlushPending isn't all that hot. We can close this PR if we don't like the readability. |
commit: |
|
| Playground | Link |
|---|---|
| React demo | https://livecodes.io?x=id/DARQFBG5R |
See documentations for usage instructions.
c46f161 to
b30df9d
Compare
| if ( | ||
| changedAtoms.size === 0 && | ||
| mountCallbacks.size === 0 && | ||
| unmountCallbacks.size === 0 && | ||
| !storeHooks.f | ||
| ) { | ||
| return | ||
| } |
There was a problem hiding this comment.
I think changing do-while loop to while loop should be more readable and improve the performance for most cases. Only the concern is the store hook, right?
There was a problem hiding this comment.
Yeah. Also, btw flushCallbacks is not a hot path. Let me see if I can switch to a while.
There was a problem hiding this comment.
its ugly. I think I prefer the code as-written.
...
if (storeHooks.f) {
call(storeHooks.f)
}
let iterations = 0
while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size) {
if (storeHooks.f && iterations++ > 0) {
call(storeHooks.f)
}
...
}b30df9d to
9c0aed5
Compare
9c0aed5 to
1c1b3aa
Compare
1c1b3aa to
1fd8c9e
Compare
1fd8c9e to
c29f90f
Compare
Summary
Check List
pnpm run fixfor formatting and linting code and docs