Drop strings.HasPrefix when guarding strings.TrimPrefix.

There is no need to check as `TrimPrefix` does nothing if the prefix
doesn't match (see https://pkg.go.dev/strings#TrimPrefix).

Bug: 193425964
Test: m nothing
Change-Id: Ieb82e72a471800e29eb6bb54308041a9ab4173e5
This commit is contained in:
Ulya Trafimovich
2021-07-14 16:35:33 +01:00
parent 39924233e0
commit 497a09310b
2 changed files with 2 additions and 7 deletions

View File

@@ -21,7 +21,6 @@ package java
import ( import (
"fmt" "fmt"
"path/filepath" "path/filepath"
"strings"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
@@ -1462,11 +1461,7 @@ func (j *Import) IDECustomizedModuleName() string {
// TODO(b/113562217): Extract the base module name from the Import name, often the Import name // TODO(b/113562217): Extract the base module name from the Import name, often the Import name
// has a prefix "prebuilt_". Remove the prefix explicitly if needed until we find a better // has a prefix "prebuilt_". Remove the prefix explicitly if needed until we find a better
// solution to get the Import name. // solution to get the Import name.
name := j.Name() return android.RemoveOptionalPrebuiltPrefix(j.Name())
if strings.HasPrefix(name, removedPrefix) {
name = strings.TrimPrefix(name, removedPrefix)
}
return name
} }
var _ android.PrebuiltInterface = (*Import)(nil) var _ android.PrebuiltInterface = (*Import)(nil)

View File

@@ -179,7 +179,7 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
continue continue
} else if strings.HasSuffix(s, "/BaseRobolectricTest.java") { } else if strings.HasSuffix(s, "/BaseRobolectricTest.java") {
continue continue
} else if strings.HasPrefix(s, "src/") { } else {
s = strings.TrimPrefix(s, "src/") s = strings.TrimPrefix(s, "src/")
} }
r.tests = append(r.tests, s) r.tests = append(r.tests, s)