Simple refactoring of prefix related functions.
Rename the two prefix-in-list funcs so that their usages are clearer.
Also find and replace all the code that essentially does either.
This introduces additional loops in some places, but I think the added
readability and simplicity outweighs the performance degradation, which
should be negligible anyway.
Test: m nothing
Test: TreeHugger
Change-Id: I37e2276ca0c815105ed0031f23c0b1264b480e4f
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 9b0e7a5..6cb9873 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -426,7 +426,7 @@
cmd.FlagWithArg("--copy-dex-files=", "false")
}
- if !anyHavePrefix(preoptFlags, "--compiler-filter=") {
+ if !android.PrefixInList(preoptFlags, "--compiler-filter=") {
var compilerFilter string
if contains(global.SystemServerJars, module.Name) {
// Jars of system server, use the product option if it is set, speed otherwise.
@@ -618,32 +618,4 @@
return false
}
-// remove all elements in a from b, returning a new slice
-func filterOut(a []string, b []string) []string {
- var ret []string
- for _, x := range b {
- if !contains(a, x) {
- ret = append(ret, x)
- }
- }
- return ret
-}
-
-func replace(l []string, from, to string) {
- for i := range l {
- if l[i] == from {
- l[i] = to
- }
- }
-}
-
var copyOf = android.CopyOf
-
-func anyHavePrefix(l []string, prefix string) bool {
- for _, x := range l {
- if strings.HasPrefix(x, prefix) {
- return true
- }
- }
- return false
-}