Unique lists in ListSetDifference
aosp/3492712 tried to make this function deterministic,
but it accidentally changed the behavior by including
duplicate elements in the result. Unique the lists
before looping over them.
Test: Presubmits
Change-Id: I7418eec98314578c0d1966bd71a094f289035f78
diff --git a/android/util.go b/android/util.go
index e8d9301..39b9c7a 100644
--- a/android/util.go
+++ b/android/util.go
@@ -213,10 +213,12 @@
}
// ListSetDifference checks if the two lists contain the same elements. It returns
-// a boolean which is true if there is a difference, and then returns lists of elements
+// a boolean which is true if there is a difference, and then returns lists of unique elements
// that are in l1 but not l2, and l2 but not l1.
func ListSetDifference[T comparable](l1, l2 []T) (bool, []T, []T) {
listsDiffer := false
+ l1 = firstUnique(l1)
+ l2 = firstUnique(l2)
diff1 := []T{}
diff2 := []T{}
m1 := setFromList(l1)