mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08: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 {
|
||||
// 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 {
|
||||
|
|
Loading…
Reference in a new issue