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, "")
|
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 have not find fixed set matches. We look for other known cases that
|
||||||
// we can optimize.
|
// we can optimize.
|
||||||
switch {
|
switch {
|
||||||
// Literal as prefix.
|
// Prefix is literal.
|
||||||
case right == nil && len(re.Sub) == 2 && re.Sub[0].Op == syntax.OpLiteral:
|
case right == nil && re.Sub[0].Op == syntax.OpLiteral:
|
||||||
right = stringMatcherFromRegexpInternal(re.Sub[1])
|
right = stringMatcherFromRegexpInternal(re.Sub[1])
|
||||||
if right != nil {
|
if right != nil {
|
||||||
matches = []string{string(re.Sub[0].Rune)}
|
matches = []string{string(re.Sub[0].Rune)}
|
||||||
matchesCaseSensitive = !isCaseInsensitive(re.Sub[0])
|
matchesCaseSensitive = !isCaseInsensitive(re.Sub[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Literal as suffix.
|
// Suffix is literal.
|
||||||
case left == nil && len(re.Sub) == 2 && re.Sub[1].Op == syntax.OpLiteral:
|
case left == nil && re.Sub[1].Op == syntax.OpLiteral:
|
||||||
left = stringMatcherFromRegexpInternal(re.Sub[0])
|
left = stringMatcherFromRegexpInternal(re.Sub[0])
|
||||||
if left != nil {
|
if left != nil {
|
||||||
matches = []string{string(re.Sub[1].Rune)}
|
matches = []string{string(re.Sub[1].Rune)}
|
||||||
|
|
Loading…
Reference in a new issue