-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
refactor(effectScope): scopes doubly-linked list #13535
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe internal implementation of the Changes
Sequence Diagram(s)sequenceDiagram
participant ParentScope
participant ChildScope
note over ParentScope: On creation of ChildScope
ParentScope->>ChildScope: Construct ChildScope
ChildScope-->>ParentScope: Add to linked list (update head/tail and pointers)
note over ParentScope,ChildScope: On stop()
ParentScope->>ChildScope: Traverse via nextEffectScope
ChildScope-->>ParentScope: Unlink self (update prev/next pointers, head/tail)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/reactivity/src/effectScope.ts (5)
37-42
: Improve documentation for the linked list properties.The comment "sibling scope" is somewhat misleading. These properties implement a doubly linked list structure for child scope management.
Consider updating the documentation to be more descriptive:
/** - * sibling scope + * Pointer to the previous scope in the parent's linked list of child scopes + * @internal */ prevEffectScope: EffectScope | undefined + /** + * Pointer to the next scope in the parent's linked list of child scopes + * @internal + */ nextEffectScope: EffectScope | undefined
47-53
: Fix semicolon consistency.There's inconsistent semicolon usage in the linked list insertion logic.
if (activeEffectScope.scopesTail) { - this.prevEffectScope = activeEffectScope.scopesTail; - activeEffectScope.scopesTail.nextEffectScope = this; - activeEffectScope.scopesTail = this; + this.prevEffectScope = activeEffectScope.scopesTail + activeEffectScope.scopesTail.nextEffectScope = this + activeEffectScope.scopesTail = this } else { - activeEffectScope.scopes = activeEffectScope.scopesTail = this; + activeEffectScope.scopes = activeEffectScope.scopesTail = this }
64-66
: Fix semicolon consistency in pause() method.for (let child = this.scopes; child != undefined; child = child.nextEffectScope) { - child.pause(); + child.pause() }
80-82
: Fix semicolon consistency in resume() method.for (let child = this.scopes; child != undefined; child = child.nextEffectScope) { - child.resume(); + child.resume() }
141-144
: Fix semicolon consistency in stop() method.for (let child = this.scopes; child != undefined; child = child.nextEffectScope) { - child.stop(true); + child.stop(true) } - this.scopes = this.scopesTail = undefined; + this.scopes = this.scopesTail = undefined
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/reactivity/src/effectScope.ts
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules
- GitHub Check: Header rules
- GitHub Check: Pages changed
🔇 Additional comments (2)
packages/reactivity/src/effectScope.ts (2)
147-160
: Well-implemented doubly linked list removal logic!The removal logic correctly handles all edge cases:
- Updates pointers of neighboring nodes
- Properly updates parent's head pointer when removing the first node
- Properly updates parent's tail pointer when removing the last node
This ensures the linked list remains consistent after removal.
35-160
: Excellent refactoring to improve performance!The refactoring from array-based child scope management to a doubly linked list is well-executed. This change provides O(1) insertion at the tail and O(1) removal operations, which should improve performance when dealing with many child scopes that are frequently created and destroyed.
The implementation correctly maintains all invariants of a doubly linked list and properly handles edge cases during removal.
Thanks for the PR. NOTE: |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Summary by CodeRabbit