From dfd2396755152918678ccd232db441da53b82f3d Mon Sep 17 00:00:00 2001 From: suntala Date: Wed, 12 Feb 2025 16:29:49 +0100 Subject: [PATCH] Refactor output writer implementation --- src/testing/testing.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/testing/testing.go b/src/testing/testing.go index 418abfc0c1..086279ec77 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1009,12 +1009,12 @@ func (c *common) log(s string) { if l := len(s); l > 0 && (string(s[l-1]) != "\n") { s += "\n" } - cs := c.getCallSite(3) // getCallSite + log + public function + cs := c.callSite(3) // callSite + log + public function c.newOutputWriter(cs).Write([]byte(s)) } -// getCallSite retrieves and formats the file and line of the call site. -func (c *common) getCallSite(skip int) string { +// callSite retrieves and formats the file and line of the call site. +func (c *common) callSite(skip int) string { c.mu.Lock() defer c.mu.Unlock() @@ -1039,8 +1039,7 @@ func (c *common) getCallSite(skip int) string { // newOutputWriter initialises a new outputWriter with the provided call site. func (c *common) newOutputWriter(cs string) io.Writer { - b := make([]byte, 0) - return &outputWriter{c, b, cs} + return &outputWriter{c, nil, cs} } // outputWriter buffers, formats and writes input.