Skip to content

Commit

Permalink
optimization: compile regexp only once
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermehubner authored and rafaelsq committed Oct 10, 2020
1 parent 003cbde commit 8ee7709
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/wtc/wtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var (
var (
logger chan Rune
templateRegex = regexp.MustCompile(`\{\{\.([^}]+)\}\}`)
exportRe = regexp.MustCompile(`(i?)export\s+`)
replaceEnvRe = regexp.MustCompile(`(i?)\%\{[A-Z0-9_]+\}\%`)

TimeFormat = "15:04:05"

Expand Down Expand Up @@ -448,9 +450,6 @@ func trig(rule *Rule, pkg, path string) error {

cmd := strings.Replace(strings.Replace(rule.Command, "{PKG}", pkg, -1), "{FILE}", path, -1)

exportRe := regexp.MustCompile(`(i?)export\s+`)
replaceEnvRe := regexp.MustCompile(`(i?)\%\{[A-Z0-9_]+\}\%`)

keys := map[string]string{}
envs := os.Environ()
for _, v := range envs {
Expand Down

0 comments on commit 8ee7709

Please sign in to comment.