mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Address offline feedback
Signed-off-by: Marco Pracucci <marco@pracucci.com>
This commit is contained in:
parent
5ae9c194ce
commit
3ed2ca3c4c
|
@ -528,20 +528,20 @@ func stringMatcherFromRegexpInternal(re *syntax.Regexp) StringMatcher {
|
|||
|
||||
matches, matchesCaseSensitive := findSetMatchesInternal(re, "")
|
||||
|
||||
if len(matches) == 0 {
|
||||
if len(matches) == 0 && len(re.Sub) == 2 {
|
||||
// We have not find fixed set matches. We look for other known cases that
|
||||
// we can optimize.
|
||||
switch {
|
||||
// Literal as prefix.
|
||||
case right == nil && len(re.Sub) == 2 && re.Sub[0].Op == syntax.OpLiteral:
|
||||
// Prefix is literal.
|
||||
case right == nil && re.Sub[0].Op == syntax.OpLiteral:
|
||||
right = stringMatcherFromRegexpInternal(re.Sub[1])
|
||||
if right != nil {
|
||||
matches = []string{string(re.Sub[0].Rune)}
|
||||
matchesCaseSensitive = !isCaseInsensitive(re.Sub[0])
|
||||
}
|
||||
|
||||
// Literal as suffix.
|
||||
case left == nil && len(re.Sub) == 2 && re.Sub[1].Op == syntax.OpLiteral:
|
||||
// Suffix is literal.
|
||||
case left == nil && re.Sub[1].Op == syntax.OpLiteral:
|
||||
left = stringMatcherFromRegexpInternal(re.Sub[0])
|
||||
if left != nil {
|
||||
matches = []string{string(re.Sub[1].Rune)}
|
||||
|
|
Loading…
Reference in a new issue