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
This commit is contained in:
@@ -122,7 +122,7 @@ func InList(s string, list []string) bool {
|
||||
}
|
||||
|
||||
// Returns true if the given string s is prefixed with any string in the given prefix list.
|
||||
func PrefixInList(s string, prefixList []string) bool {
|
||||
func HasAnyPrefix(s string, prefixList []string) bool {
|
||||
for _, prefix := range prefixList {
|
||||
if strings.HasPrefix(s, prefix) {
|
||||
return true
|
||||
@@ -132,7 +132,7 @@ func PrefixInList(s string, prefixList []string) bool {
|
||||
}
|
||||
|
||||
// Returns true if any string in the given list has the given prefix.
|
||||
func PrefixedStringInList(list []string, prefix string) bool {
|
||||
func PrefixInList(list []string, prefix string) bool {
|
||||
for _, s := range list {
|
||||
if strings.HasPrefix(s, prefix) {
|
||||
return true
|
||||
|
Reference in New Issue
Block a user