perf(observer): add early return in Dep.notify() when subs is empty - #13369
Open
ifer47 wants to merge 1 commit into
Open
perf(observer): add early return in Dep.notify() when subs is empty#13369ifer47 wants to merge 1 commit into
ifer47 wants to merge 1 commit into
Conversation
After filtering out null subscribers, if no subscribers remain, return early to avoid unnecessary sorting (in dev sync mode) and loop iteration. This avoids creating an empty sorted array and entering a zero-iteration loop. Closes vuejs#13019 Co-Authored-By: zhipu/glm-5 <zai-org@claude-code-best.win>
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.
Summary
Dep.notify()when the filtered subscriber list is emptyProblem
In
Dep.notify(), after filtering null subscribers withthis.subs.filter(s => s), the method proceeds even when the resultingsubsarray is empty. This means in dev sync mode, it will unnecessarily sort an empty array, and then enter a zero-iteration for loop.Changes
Added
if (subs.length === 0) returnafter the subs filtering inDep.notify().Closes #13019
🤖 Generated with Claude Code Best