diff options
author | 2025-02-12 21:21:04 -0800 | |
---|---|---|
committer | 2025-02-13 11:28:22 -0800 | |
commit | 846761cd03e4d834cf4e62e8710e2d25f850a468 (patch) | |
tree | bed4022060c96b27ad7e1226051904d2c8ed6e79 | |
parent | c0a00df42e8f63caa3070c80a1e40db22bc574cc (diff) |
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
-rw-r--r-- | android/util.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/android/util.go b/android/util.go index e8d9301dd..39b9c7a78 100644 --- a/android/util.go +++ b/android/util.go @@ -213,10 +213,12 @@ func PrettyConcat(list []string, quote bool, lastSep string) string { } // 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) |