]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/trace: use strings.Builder
authorcuiweixie <cuiweixie@gmail.com>
Sun, 4 Sep 2022 12:14:47 +0000 (20:14 +0800)
committerGopher Robot <gobot@golang.org>
Thu, 8 Sep 2022 14:33:45 +0000 (14:33 +0000)
Change-Id: I690dc517c08be4cd66439baad8b91f16622ff0d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/428292
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/trace/annotations.go

index 1c0dad56d849e6af89f30f5cf405e0598d72f967..a276d7b642815d987d6598b09079d57827cedebd 100644 (file)
@@ -370,7 +370,7 @@ func (task *taskDesc) String() string {
        if task == nil {
                return "task <nil>"
        }
-       wb := new(bytes.Buffer)
+       wb := new(strings.Builder)
        fmt.Fprintf(wb, "task %d:\t%s\n", task.id, task.name)
        fmt.Fprintf(wb, "\tstart: %v end: %v complete: %t\n", task.firstTimestamp(), task.endTimestamp(), task.complete())
        fmt.Fprintf(wb, "\t%d goroutines\n", len(task.goroutines))
@@ -872,7 +872,7 @@ func (h *durationHistogram) ToHTML(urlmaker func(min, max time.Duration) string)
                }
        }
 
-       w := new(bytes.Buffer)
+       w := new(strings.Builder)
        fmt.Fprintf(w, `<table>`)
        for i := h.MinBucket; i <= h.MaxBucket; i++ {
                // Tick label.
@@ -914,7 +914,7 @@ func (h *durationHistogram) String() string {
                }
        }
 
-       w := new(bytes.Buffer)
+       w := new(strings.Builder)
        for i := h.MinBucket; i <= h.MaxBucket; i++ {
                count := h.Buckets[i]
                bar := count * barWidth / maxCount