mirror of
https://github.com/prometheus/prometheus
synced 2024-12-23 23:13:11 +00:00
Optimize containsInOrder() inlining it
Signed-off-by: Marco Pracucci <marco@pracucci.com>
This commit is contained in:
parent
a0807733be
commit
d966ae6400
@ -941,6 +941,15 @@ func hasSuffixCaseInsensitive(s, suffix string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func containsInOrder(s string, contains []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
|
offset := 0
|
||||||
|
|
||||||
for _, substr := range contains {
|
for _, substr := range contains {
|
||||||
|
Loading…
Reference in New Issue
Block a user