Skip to content

Commit

Permalink
use TopologicalOrder for evaluating moves
Browse files Browse the repository at this point in the history
The dag package did not previously provide a topological walk of a given
graph. While the existing combination of a transitive reduction with a
depth-first walk appeared to accomplish this, depth-first is only
equivalent with a simple tree. If there are multiple paths to a node, a
depth-first approach will skip dependencies from alternate paths.
  • Loading branch information
jbardin committed Jul 22, 2022
1 parent a2c4ed3 commit 0e64be0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions internal/refactoring/move_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func ApplyMoves(stmts []MoveStatement, state *states.State) MoveResults {
}
}

g.ReverseDepthFirstWalk(startNodes, func(v dag.Vertex, depth int) error {
for _, v := range g.ReverseTopologicalOrder() {
stmt := v.(*MoveStatement)

for _, ms := range state.Modules {
Expand Down Expand Up @@ -187,9 +187,7 @@ func ApplyMoves(stmts []MoveStatement, state *states.State) MoveResults {
panic(fmt.Sprintf("unhandled move object kind %s", kind))
}
}

return nil
})
}

return ret
}
Expand Down

0 comments on commit 0e64be0

Please sign in to comment.