Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
This commit is contained in:
Cyril Tovena 2021-10-06 09:13:40 +02:00
parent 0bb2d1954b
commit 17a558336b
No known key found for this signature in database
GPG key ID: FD8F768F9D633FB6

View file

@ -243,7 +243,12 @@ func optimizeConcatRegex(r *syntax.Regexp) (prefix, suffix, contains string) {
} }
// todo remove anchors ^foo$ // 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 { func contains(s, substr string) bool {
pos := strings.Index(s, substr) pos := strings.Index(s, substr)
@ -254,6 +259,7 @@ func contains(s, substr string) bool {
} }
func matchesAnyZeroOrMoreNotNL(s string) bool { func matchesAnyZeroOrMoreNotNL(s string) bool {
// strings.Contains(s string, substr string) faster ??
for _, r := range s { for _, r := range s {
if r == '\n' { if r == '\n' {
return false return false