diff --git a/android/apex.go b/android/apex.go index 5dcf73bc6..823afbb11 100644 --- a/android/apex.go +++ b/android/apex.go @@ -513,9 +513,8 @@ func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) { // exactly the same set of APEXes (and platform), i.e. if their apex_available // properties have the same elements. func AvailableToSameApexes(mod1, mod2 ApexModule) bool { - // Use CopyOf to prevent non-determinism (b/275313114#comment1) - mod1ApexAvail := SortedUniqueStrings(CopyOf(mod1.apexModuleBase().ApexProperties.Apex_available)) - mod2ApexAvail := SortedUniqueStrings(CopyOf(mod2.apexModuleBase().ApexProperties.Apex_available)) + mod1ApexAvail := SortedUniqueStrings(mod1.apexModuleBase().ApexProperties.Apex_available) + mod2ApexAvail := SortedUniqueStrings(mod2.apexModuleBase().ApexProperties.Apex_available) if len(mod1ApexAvail) != len(mod2ApexAvail) { return false } diff --git a/android/util.go b/android/util.go index 38e0a4dbb..fb09128f8 100644 --- a/android/util.go +++ b/android/util.go @@ -276,6 +276,8 @@ func RemoveFromList(s string, list []string) (bool, []string) { // FirstUniqueStrings returns all unique elements of a slice of strings, keeping the first copy of // each. It modifies the slice contents in place, and returns a subslice of the original slice. func FirstUniqueStrings(list []string) []string { + // Do not moodify the input in-place, operate on a copy instead. + list = CopyOf(list) // 128 was chosen based on BenchmarkFirstUniqueStrings results. if len(list) > 128 { return firstUniqueStringsMap(list) @@ -332,6 +334,7 @@ func LastUniqueStrings(list []string) []string { // SortedUniqueStrings returns what the name says func SortedUniqueStrings(list []string) []string { + // FirstUniqueStrings creates a copy of `list`, so the input remains untouched. unique := FirstUniqueStrings(list) sort.Strings(unique) return unique