Write ninja file in parallel.
Bug: 335718784 Test: CI Change-Id: Ie36d78478a60359b704767689846e76b1c2ba76d
This commit is contained in:
@@ -24,6 +24,8 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
// CopyOf returns a new slice that has the same contents as s.
|
||||
@@ -542,25 +544,9 @@ func SplitFileExt(name string) (string, string, string) {
|
||||
return root, suffix, ext
|
||||
}
|
||||
|
||||
func shard[T ~[]E, E any](toShard T, shardSize int) []T {
|
||||
if len(toShard) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
ret := make([]T, 0, (len(toShard)+shardSize-1)/shardSize)
|
||||
for len(toShard) > shardSize {
|
||||
ret = append(ret, toShard[0:shardSize])
|
||||
toShard = toShard[shardSize:]
|
||||
}
|
||||
if len(toShard) > 0 {
|
||||
ret = append(ret, toShard)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// ShardPaths takes a Paths, and returns a slice of Paths where each one has at most shardSize paths.
|
||||
func ShardPaths(paths Paths, shardSize int) []Paths {
|
||||
return shard(paths, shardSize)
|
||||
return proptools.ShardBySize(paths, shardSize)
|
||||
}
|
||||
|
||||
// ShardString takes a string and returns a slice of strings where the length of each one is
|
||||
@@ -583,7 +569,7 @@ func ShardString(s string, shardSize int) []string {
|
||||
// ShardStrings takes a slice of strings, and returns a slice of slices of strings where each one has at most shardSize
|
||||
// elements.
|
||||
func ShardStrings(s []string, shardSize int) [][]string {
|
||||
return shard(s, shardSize)
|
||||
return proptools.ShardBySize(s, shardSize)
|
||||
}
|
||||
|
||||
// CheckDuplicate checks if there are duplicates in given string list.
|
||||
|
Reference in New Issue
Block a user