refactor(route): remove unreachable backtracking branch for akind node - #1511
Open
Lcos-000 wants to merge 1 commit into
Open
refactor(route): remove unreachable backtracking branch for akind node#1511Lcos-000 wants to merge 1 commit into
Lcos-000 wants to merge 1 commit into
Conversation
Contributor
Author
|
After further consideration, I think a conservative approach might be better here — keep the original logic and just add a comment explaining why the akind branch is unreachable (see #1504 for analysis). This avoids any behavioral change on the hot path. Happy to update this PR or open a new one, whichever the maintainers prefer. |
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.
What type of PR is this?
refactor
Check the PR title.
refactor(route): remove unreachable backtracking branch for akind node
(Optional) Translate the PR title into Chinese.
重构(route): 移除 any 节点回溯逻辑中的不可达分支
(Optional) More detailed description for this PR.
en:
While reading pkg/route/tree.go, the following logic was noticed in backtrackToNextNodeKind():
if previous.kind == akind {
nextNodeKind = skind
} else {
nextNodeKind = previous.kind + 1
}
The previous.kind == akind branch appears to be unreachable in the current implementation.
Evidence:
Change: Removed the special case, simplifying to nextNodeKind = previous.kind + 1. No functional change. All existing tests pass.
zh(optional):
在阅读 pkg/route/tree.go 时,发现 backtrackToNextNodeKind() 中存在以下逻辑:
if previous.kind == akind {
nextNodeKind = skind
} else {
nextNodeKind = previous.kind + 1
}
其中 previous.kind == akind 分支在当前实现中似乎是不可达的。
分析:
修改:移除特殊分支,简化为 nextNodeKind = previous.kind + 1。无功能变更,所有已有测试均通过。
(Optional) Which issue(s) this PR fixes:
Fixes #1504
(Optional) The PR that updates user documentation: