Merge "Do not modify input in-place" into udc-dev am: 4f0c490ac9
Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/23374037 Change-Id: I5049264e5e1976952f87e5dcd58ee1db32489623 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -280,6 +280,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)
|
||||
@@ -336,6 +338,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
|
||||
|
Reference in New Issue
Block a user