Optimize containsInOrder() inlining it

Signed-off-by: Marco Pracucci <marco@pracucci.com>
This commit is contained in:
Marco Pracucci 2024-06-04 10:24:36 +02:00
parent a0807733be
commit d966ae6400
No known key found for this signature in database
GPG Key ID: 74C1BD403D2DF9B5

View File

@ -941,6 +941,15 @@ func hasSuffixCaseInsensitive(s, suffix string) bool {
}
func containsInOrder(s string, contains []string) bool {
// Optimization for the case we only have to look for 1 substring.
if len(contains) == 1 {
return strings.Contains(s, contains[0])
}
return containsInOrderMulti(s, contains)
}
func containsInOrderMulti(s string, contains []string) bool {
offset := 0
for _, substr := range contains {