From 17a558336b9a7cb4d9511affce91fc38b8939c79 Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Wed, 6 Oct 2021 09:13:40 +0200 Subject: [PATCH] wip Signed-off-by: Cyril Tovena --- pkg/labels/regexp.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/labels/regexp.go b/pkg/labels/regexp.go index 519c1c1763..d8c0a13484 100644 --- a/pkg/labels/regexp.go +++ b/pkg/labels/regexp.go @@ -243,7 +243,12 @@ func optimizeConcatRegex(r *syntax.Regexp) (prefix, suffix, contains string) { } // todo remove anchors ^foo$ -// .*POD.* +// remove captures. +// .+ | .* | .*POD.* | 5.. | test-.* | .*-test | test-.+ | .+-test + +// regexp prefix fn ???? can we use this ? + +// benchmark them func contains(s, substr string) bool { pos := strings.Index(s, substr) @@ -254,6 +259,7 @@ func contains(s, substr string) bool { } func matchesAnyZeroOrMoreNotNL(s string) bool { + // strings.Contains(s string, substr string) faster ?? for _, r := range s { if r == '\n' { return false