Use common helper functions for getting sorted map keys.

Add a new helper SortedIntKeys similar to SortedStringKeys.

Test: lunch aosp_cf_x86_phone-userdebug && m
Change-Id: I08a43ec2cae7d1a82531295aca1a0658e3a0dd6f
This commit is contained in:
Ulya Trafimovich
2020-08-20 11:33:12 +01:00
parent 9ce2221791
commit b8063c6a86
5 changed files with 17 additions and 24 deletions

View File

@@ -17,7 +17,6 @@ package dexpreopt
import (
"encoding/json"
"fmt"
"sort"
"strings"
"github.com/google/blueprint"
@@ -142,16 +141,6 @@ func (libPaths LibraryPaths) AddLibraryPaths(otherPaths LibraryPaths) {
}
}
// Return sorted names of the libraries in the map.
func (libPaths LibraryPaths) Names() []string {
keys := make([]string, 0, len(libPaths))
for k := range libPaths {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
}
type ModuleConfig struct {
Name string
DexLocation string // dex location on device

View File

@@ -37,7 +37,6 @@ import (
"fmt"
"path/filepath"
"runtime"
"sort"
"strings"
"android/soong/android"
@@ -208,15 +207,6 @@ type classLoaderContextMap map[int]*classLoaderContext
const anySdkVersion int = 9999 // should go last in class loader context
func (m classLoaderContextMap) getSortedKeys() []int {
keys := make([]int, 0, len(m))
for k := range m {
keys = append(keys, k)
}
sort.Ints(keys)
return keys
}
func (m classLoaderContextMap) getValue(sdkVer int) *classLoaderContext {
if _, ok := m[sdkVer]; !ok {
m[sdkVer] = &classLoaderContext{}
@@ -342,7 +332,7 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g
cmd := rule.Command().
Text(`eval "$(`).Tool(globalSoong.ConstructContext).
Text(` --target-sdk-version ${target_sdk_version}`)
for _, ver := range classLoaderContexts.getSortedKeys() {
for _, ver := range android.SortedIntKeys(classLoaderContexts) {
clc := classLoaderContexts.getValue(ver)
verString := fmt.Sprintf("%d", ver)
if ver == anySdkVersion {