Skip to content

Commit

Permalink
added TODO for bug where multiple paths may have equal differences wi…
Browse files Browse the repository at this point in the history
…th the comparing path, not sure which to use

Signed-off-by: Soham Arora <arorasoham9@gmail.com>
  • Loading branch information
arorasoham9 committed Jul 12, 2024
1 parent dd2ebb7 commit 5795cfc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ type DiffResult struct {
Nodes map[string]DiffedNodePair
}

type EqualDifferencesPaths struct {
Diffs [][]string
Path []*Node
Index int
}

type DiffedNodePair struct {
NodeOne *Node
NodeTwo *Node
Expand Down Expand Up @@ -880,6 +886,7 @@ func CompareAllPaths(listOne, listTwo [][]*Node) (DiffResult, error) {
pathDiff.PathOne = pathOne
min := math.MaxInt32
var index int
diffIndices := []EqualDifferencesPaths{}

for i, pathTwo := range big {
_, ok := used[i]
Expand All @@ -893,15 +900,26 @@ func CompareAllPaths(listOne, listTwo [][]*Node) (DiffResult, error) {
return DiffResult{}, fmt.Errorf(err.Error())
}



if diffNum < min {
pathDiff.PathTwo = pathTwo
min = diffNum
pathDiff.Diffs = diffs
index = i
diffIndices = []EqualDifferencesPaths{{Diffs: diffs, Path: pathTwo, Index: i}}
} else if diffNum == min {
diffIndices = append(diffIndices, EqualDifferencesPaths{Diffs: diffs, Path: pathTwo, Index: i})
}
}

used[index] = true
if len(diffIndices) == 1 {
used[index] = true
}else{
//TODO: how to fix problem where there are multiple paths to compare with only 1 difference?
used[index] = true //remove this when TODO is resolved
}


count := 0
seenNodeIndex := -1
Expand Down

0 comments on commit 5795cfc

Please sign in to comment.