Skip to content

Commit 790d3af

Browse files
committed
CleanGitEnv(): pre-allocate the env slice
1 parent 33b4b53 commit 790d3af

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/testutils/repoutils.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ var localEnvVars = func() map[string]bool {
112112
// CleanGitEnv returns a clean environment for running `git` commands
113113
// so that they won't be affected by the local environment.
114114
func CleanGitEnv() []string {
115-
var env []string
116-
for _, e := range os.Environ() {
115+
osEnv := os.Environ()
116+
env := make([]string, 0, len(osEnv)+3)
117+
for _, e := range osEnv {
117118
i := strings.IndexByte(e, '=')
118119
if i == -1 {
119120
// This shouldn't happen, but if it does,

0 commit comments

Comments
 (0)