Unverified Commit ce46922b authored by 0xADADA's avatar 0xADADA Committed by GitHub

speeds O(n^2) execution of detectConflictingPaths (#46080)



## Bug

- [x] Related issues linked using `fixes #46079` https://github.com/vercel/next.js/issues/46079
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent d7b479a8
...@@ -1554,6 +1554,17 @@ export function detectConflictingPaths( ...@@ -1554,6 +1554,17 @@ export function detectConflictingPaths(
>() >()
const dynamicSsgPages = [...ssgPages].filter((page) => isDynamicRoute(page)) const dynamicSsgPages = [...ssgPages].filter((page) => isDynamicRoute(page))
const additionalSsgPathsByPath: {
[page: string]: { [path: string]: string }
} = {}
additionalSsgPaths.forEach((paths, pathsPage) => {
additionalSsgPathsByPath[pathsPage] ||= {}
paths.forEach((curPath) => {
const currentPath = curPath.toLowerCase()
additionalSsgPathsByPath[pathsPage][currentPath] = curPath
})
})
additionalSsgPaths.forEach((paths, pathsPage) => { additionalSsgPaths.forEach((paths, pathsPage) => {
paths.forEach((curPath) => { paths.forEach((curPath) => {
...@@ -1573,9 +1584,10 @@ export function detectConflictingPaths( ...@@ -1573,9 +1584,10 @@ export function detectConflictingPaths(
conflictingPage = dynamicSsgPages.find((page) => { conflictingPage = dynamicSsgPages.find((page) => {
if (page === pathsPage) return false if (page === pathsPage) return false
conflictingPath = additionalSsgPaths conflictingPath =
.get(page) additionalSsgPaths.get(page) == null
?.find((compPath) => compPath.toLowerCase() === lowerPath) ? undefined
: additionalSsgPathsByPath[page][lowerPath]
return conflictingPath return conflictingPath
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment