Skip to content

Commit 0985cb9

Browse files
committed
HistorySize.TableString(): generate table header here
1 parent c88525b commit 0985cb9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

sizes/output.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,7 @@ func (s *section) Emit(t *table, buf io.Writer, indent int) {
114114
}
115115

116116
// There's output, so emit the section header first:
117-
if indent == -1 {
118-
// As a special case, the top-level section doesn't have its
119-
// own header, but prints the table header:
120-
fmt.Fprint(buf, t.generateHeader())
121-
} else {
117+
if s.name != "" {
122118
t.formatSectionHeader(buf, indent, s.name)
123119
}
124120

@@ -332,8 +328,12 @@ func (s HistorySize) TableString(threshold Threshold, nameStyle NameStyle) strin
332328

333329
buf := &bytes.Buffer{}
334330
t.contents.Emit(&t, buf, -1)
335-
linesString := buf.String()
336-
return linesString + t.footnotes.String()
331+
332+
if buf.Len() == 0 {
333+
return ""
334+
}
335+
336+
return t.generateHeader() + buf.String() + t.footnotes.String()
337337
}
338338

339339
func (t *table) generateHeader() string {

0 commit comments

Comments
 (0)