Skip to content

Commit 517fd31

Browse files
committed
fix: sort deps deterministically to prevent worst case scenario orders that could increase runtime drastically
1 parent 59daf28 commit 517fd31

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ func (s *state) sawMod(path string) {
159159

160160
func (s *state) transitiveReduction() {
161161
noPath := make(map[string]map[string]struct{}) // [path][path]
162-
for m, deps := range s.deps {
162+
163+
// Iterate modules in a stable order
164+
mods := slices.Sorted(maps.Keys(s.deps))
165+
for _, m := range mods {
166+
deps := s.deps[m]
163167
s.deps[m] = slices.DeleteFunc(deps, func(d string) bool {
164168
// BFS for indirect paths to d, tracking nodes we touch along the way
165169
var touched []string

0 commit comments

Comments
 (0)