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:
Jaewoong Jung
2020-02-11 07:54:35 -08:00
parent 1d62b1c536
commit 3aff5787e2
12 changed files with 29 additions and 107 deletions

View File

@@ -252,7 +252,7 @@ func TestPrefixInList(t *testing.T) {
for _, testCase := range testcases {
t.Run(testCase.str, func(t *testing.T) {
out := PrefixInList(testCase.str, prefixes)
out := HasAnyPrefix(testCase.str, prefixes)
if out != testCase.expected {
t.Errorf("incorrect output:")
t.Errorf(" str: %#v", testCase.str)