Skip to content
/ router Public
  • Sponsor vuejs/router

  • Notifications You must be signed in to change notification settings
  • Fork 1.2k
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

perf: use a binary search for insertMatcher #2137

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: docs and logs
posva committed Jun 10, 2024
commit 87320b738b21f6289f5ac79e4e0762ba32c8584d
11 changes: 9 additions & 2 deletions packages/router/src/matcher/index.ts
Original file line number Diff line number Diff line change
@@ -545,10 +545,10 @@
if (insertionAncestor) {
upper = matchers.lastIndexOf(insertionAncestor, upper - 1)

if (__DEV__ && upper === -1) {
if (__DEV__ && upper < 0) {
// This should never happen
warn(

Check warning on line 550 in packages/router/src/matcher/index.ts

Codecov / codecov/patch

packages/router/src/matcher/index.ts#L550

Added line #L550 was not covered by tests
`Finding ancestor route ${insertionAncestor.record.path} failed for ${matcher.record.path}`
`Finding ancestor route "${insertionAncestor.record.path}" failed for "${matcher.record.path}"`
)
}
}
@@ -571,6 +571,13 @@
return
}

/**
* Checks if a matcher can be reachable. This means if it's possible to reach it as a route. For example, routes without
* a component, or name, or redirect, are just used to group other routes.
* @param matcher
* @param matcher.record record of the matcher
* @returns
*/
function isMatchable({ record }: RouteRecordMatcher): boolean {
return !!(
record.name ||