Skip to content

Commit

Permalink
Merge pull request #245 from Juneezee/master
Browse files Browse the repository at this point in the history
Avoid allocations with `(*regexp.Regexp).MatchString`
  • Loading branch information
fatihbaltaci authored Nov 7, 2023
2 parents bcd58f3 + bc5c178 commit ffc945f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/types/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (s *Scenario) validate() error {

// add global envs
for key := range s.Envs {
if !envVarNameRegexp.Match([]byte(key)) { // not a valid env definition
if !envVarNameRegexp.MatchString(key) { // not a valid env definition
return fmt.Errorf("env key is not valid: %s", key)
}
definedEnvs[key] = struct{}{} // exist
Expand All @@ -98,7 +98,7 @@ func (s *Scenario) validate() error {
return fmt.Errorf("csv key can not have dot in it: %s", key)
}
for _, s := range splitted {
if !envVarNameRegexp.Match([]byte(s)) { // not a valid env definition
if !envVarNameRegexp.MatchString(s) { // not a valid env definition
return fmt.Errorf("csv key is not valid: %s", key)
}
}
Expand All @@ -112,7 +112,7 @@ func (s *Scenario) validate() error {

// enrich Envs map with captured envs from each step
for _, ce := range st.EnvsToCapture {
if !envVarNameRegexp.Match([]byte(ce.Name)) { // not a valid env definition
if !envVarNameRegexp.MatchString(ce.Name) { // not a valid env definition
return fmt.Errorf("captured env key is not valid: %s", ce.Name)
}
definedEnvs[ce.Name] = struct{}{}
Expand Down

0 comments on commit ffc945f

Please sign in to comment.