Do not modify input in-place
SortedUniqueStrings and FirstUniqueStrings dedupes repeating elements and returns the deduped list. Currently, it also modifies the input list in-place, which causes non-determinisitc failures like b/275313114 Operate on a copy of the input so that the input remains untouched. SortedUniqueStrings is O(NlogN) and FirstUniqueStrings is ~O(N), so creating a copy (O(N)) should not result in major performance regressions. Numbers for this single unit test: ``` go test . -run TestStubsForLibraryInMultipleApexes -v -count 1000 Before: 174s After: 172s ``` Test: go test ./android Test: go test . -run TestStubsForLibraryInMultipleApexes -v -count 1000 Change-Id: Id859723b2c2ebdc0023876c4b6fabe75d870bad7
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user