Skip to content

Commit 8a61785

Browse files
author
suntala
committed
Refactor output writer implementation
1 parent 59f309a commit 8a61785

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/testing/testing.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,12 +1009,12 @@ func (c *common) log(s string) {
10091009
if l := len(s); l > 0 && (string(s[l-1]) != "\n") {
10101010
s += "\n"
10111011
}
1012-
cs := c.getCallSite(3) // getCallSite + log + public function
1012+
cs := c.callSite(3) // callSite + log + public function
10131013
c.newOutputWriter(cs).Write([]byte(s))
10141014
}
10151015

1016-
// getCallSite retrieves and formats the file and line of the call site.
1017-
func (c *common) getCallSite(skip int) string {
1016+
// callSite retrieves and formats the file and line of the call site.
1017+
func (c *common) callSite(skip int) string {
10181018
c.mu.Lock()
10191019
defer c.mu.Unlock()
10201020

@@ -1039,8 +1039,7 @@ func (c *common) getCallSite(skip int) string {
10391039

10401040
// newOutputWriter initialises a new outputWriter with the provided call site.
10411041
func (c *common) newOutputWriter(cs string) io.Writer {
1042-
b := make([]byte, 0)
1043-
return &outputWriter{c, b, cs}
1042+
return &outputWriter{c, nil, cs}
10441043
}
10451044

10461045
// outputWriter buffers, formats and writes input.

0 commit comments

Comments
 (0)