Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
0e01108f
Commit
0e01108f
authored
Jul 16, 2025
by
Luke Sandberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comments
parent
0af26f38
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
client_references.rs
crates/next-api/src/client_references.rs
+9
-7
No files found.
crates/next-api/src/client_references.rs
View file @
0e01108f
...
...
@@ -132,25 +132,25 @@ pub async fn map_client_references(
return
Some
(
Rc
::
from
(
vec!
[
u
]));
}
// 1. Memoization check: If already computed, return cached result.
// Memoization check: If already computed, return cached result.
// From any given node in a directed graph the DFS result is the same
if
let
Some
(
cached_result
)
=
memo
.get
(
&
u
)
{
return
cached_result
.clone
();
}
// 2. Cycle detection: If 'u' is currently in recursion stack, it's a cycle.
// For DFS post-order, we simply don't add 'u' or its descendants from this path
// until the cycle is naturally broken or handled by memoization from another path.
// Check for cycles, treat as empty since we are already visiting it, but we don't store
// in the memo
if
!
visiting_stack
.insert
(
u
)
{
return
None
;
}
// 3. Recursively visit neighbors or consume ourselves, we don't consider client
// references to be traversable.
// Recursively visit neighbors
let
mut
transitive_client_refs
=
None
;
let
mut
first
=
None
;
for
v
in
graph
.neighbors
(
u
)
{
// This ignores back edges because we must have already visited them.
// This ignores back edges because we must have already visited them and of course
// empty subgraphs as well.
if
let
Some
(
green_nodes_from_v
)
=
dfs_collect_shallow_client_references
(
false
,
v
,
...
...
@@ -162,6 +162,8 @@ pub async fn map_client_references(
// Merge results from sub-paths
// Save the first one on the relatively likely chance that we don't actually
// accumulate _more_.
// This is the most expensive part of the traversal, accumulating the ordered
// sets.
match
&
first
{
None
=>
{
first
=
Some
(
green_nodes_from_v
.clone
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment