mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
refactor(wildcard): optimize and add caching (#1634)
* fix(wildcard): avoid excessive allocations every loop * are you going to Scarborough Fair? * ruby ruby ruby ruby * ride on, little murphy * shirley? * to the moon * reggie are you there? * code 99 * my doctorate is in Art History * helps to be consistent * tidy * slow and steady gets the clam * oysters were better anyway * DIAL TONE
This commit is contained in:
parent
bc0f4cc055
commit
982f7ddf68
13 changed files with 177 additions and 60 deletions
|
@ -2,8 +2,8 @@ package indexer
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"regexp"
|
||||
|
||||
"github.com/autobrr/autobrr/pkg/regexcache"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
|
@ -12,7 +12,7 @@ type Logger interface {
|
|||
}
|
||||
|
||||
func regExMatch(pattern string, value string) ([]string, error) {
|
||||
rxp, err := regexp.Compile(pattern)
|
||||
rxp, err := regexcache.Compile(pattern)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ func parseExtract(logger Logger, pattern string, vars []string, tmpVars map[stri
|
|||
}
|
||||
|
||||
func parseMatchRegexp(pattern string, tmpVars map[string]string, line string, ignore bool) (bool, error) {
|
||||
var re = regexp.MustCompile(`(?mi)` + pattern)
|
||||
var re = regexcache.MustCompile(`(?mi)` + pattern)
|
||||
|
||||
groupNames := re.SubexpNames()
|
||||
for _, match := range re.FindAllStringSubmatch(line, -1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue