Skip to content

Commit fadbf20

Browse files
authored
Merge pull request #3811 from buildkite/compile-regexp-once
fix: compile badChars regexp once
2 parents 27ca920 + e676c13 commit fadbf20

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/job/executor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,14 +807,14 @@ func (e *Executor) executeLocalHook(ctx context.Context, name string) error {
807807
})
808808
}
809809

810+
var badCharsRE = regexp.MustCompile("[[:^alnum:]]")
811+
810812
func dirForAgentName(agentName string) string {
811-
badCharsPattern := regexp.MustCompile("[[:^alnum:]]")
812-
return badCharsPattern.ReplaceAllString(agentName, "-")
813+
return badCharsRE.ReplaceAllString(agentName, "-")
813814
}
814815

815816
func dirForRepository(repository string) string {
816-
badCharsPattern := regexp.MustCompile("[[:^alnum:]]")
817-
return badCharsPattern.ReplaceAllString(repository, "-")
817+
return badCharsRE.ReplaceAllString(repository, "-")
818818
}
819819

820820
// Given a repository, it will add the host to the set of SSH known_hosts on the machine

0 commit comments

Comments
 (0)