Skip to content

Commit 0d0e96d

Browse files
committed
don't make a new formatter for each GinkgoT(); that's just silly and uses precious memory
1 parent 867ce95 commit 0d0e96d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

internal/testingtproxy/testing_t_proxy.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ type ginkgoWriterInterface interface {
2727
type ginkgoRecoverFunc func()
2828
type attachProgressReporterFunc func(func() string) func()
2929

30+
var formatters = map[bool]formatter.Formatter{
31+
true: formatter.NewWithNoColorBool(true),
32+
false: formatter.NewWithNoColorBool(false),
33+
}
34+
3035
func New(writer ginkgoWriterInterface, fail failFunc, skip skipFunc, cleanup cleanupFunc, report reportFunc, addReportEntry addReportEntryFunc, ginkgoRecover ginkgoRecoverFunc, attachProgressReporter attachProgressReporterFunc, randomSeed int64, parallelProcess int, parallelTotal int, noColor bool, offset int) *ginkgoTestingTProxy {
3136
return &ginkgoTestingTProxy{
3237
fail: fail,
@@ -41,7 +46,7 @@ func New(writer ginkgoWriterInterface, fail failFunc, skip skipFunc, cleanup cle
4146
randomSeed: randomSeed,
4247
parallelProcess: parallelProcess,
4348
parallelTotal: parallelTotal,
44-
f: formatter.NewWithNoColorBool(noColor),
49+
f: formatters[noColor], //minimize allocations by reusing formatters
4550
}
4651
}
4752

0 commit comments

Comments
 (0)