@@ -86,22 +86,22 @@ type section struct {
86
86
contents []tableContents
87
87
}
88
88
89
- func newSection (name string , contents ... tableContents ) * section {
90
- return & section {
89
+ func newSection (name string , contents ... tableContents ) section {
90
+ return section {
91
91
name : name ,
92
92
contents : contents ,
93
93
}
94
94
}
95
95
96
- func (s * section ) Emit (t * table ) {
96
+ func (s section ) Emit (t * table ) {
97
97
for _ , c := range s .contents {
98
98
subTable := t .subTable (s .name )
99
99
c .Emit (subTable )
100
100
t .addSection (subTable )
101
101
}
102
102
}
103
103
104
- func (s * section ) CollectItems (items map [string ]* item ) {
104
+ func (s section ) CollectItems (items map [string ]* item ) {
105
105
for _ , c := range s .contents {
106
106
c .CollectItems (items )
107
107
}
@@ -141,7 +141,7 @@ func newItem(
141
141
}
142
142
}
143
143
144
- func (i * item ) Emit (t * table ) {
144
+ func (i item ) Emit (t * table ) {
145
145
levelOfConcern , interesting := i .levelOfConcern (t .threshold )
146
146
if ! interesting {
147
147
return
@@ -154,7 +154,7 @@ func (i *item) Emit(t *table) {
154
154
)
155
155
}
156
156
157
- func (i * item ) Footnote (nameStyle NameStyle ) string {
157
+ func (i item ) Footnote (nameStyle NameStyle ) string {
158
158
if i .path == nil || i .path .OID == git .NullOID {
159
159
return ""
160
160
}
@@ -173,7 +173,7 @@ func (i *item) Footnote(nameStyle NameStyle) string {
173
173
// If this item's alert level is at least as high as the threshold,
174
174
// return the string that should be used as its "level of concern" and
175
175
// `true`; otherwise, return `"", false`.
176
- func (i * item ) levelOfConcern (threshold Threshold ) (string , bool ) {
176
+ func (i item ) levelOfConcern (threshold Threshold ) (string , bool ) {
177
177
value , overflow := i .value .ToUint64 ()
178
178
if overflow {
179
179
return "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" , true
@@ -188,11 +188,11 @@ func (i *item) levelOfConcern(threshold Threshold) (string, bool) {
188
188
return stars [:int (alert )], true
189
189
}
190
190
191
- func (i * item ) CollectItems (items map [string ]* item ) {
192
- items [i .symbol ] = i
191
+ func (i item ) CollectItems (items map [string ]* item ) {
192
+ items [i .symbol ] = & i
193
193
}
194
194
195
- func (i * item ) MarshalJSON () ([]byte , error ) {
195
+ func (i item ) MarshalJSON () ([]byte , error ) {
196
196
// How we want to emit an item as JSON.
197
197
value , _ := i .value .ToUint64 ()
198
198
@@ -224,7 +224,7 @@ func (i *item) MarshalJSON() ([]byte, error) {
224
224
225
225
// Indented returns an `item` that is just like `i`, but indented by
226
226
// `depth` more levels.
227
- func (i * item ) Indented (depth int ) tableContents {
227
+ func (i item ) Indented (depth int ) tableContents {
228
228
return & indentedItem {
229
229
tableContents : i ,
230
230
depth : depth ,
@@ -236,7 +236,7 @@ type indentedItem struct {
236
236
depth int
237
237
}
238
238
239
- func (i * indentedItem ) Emit (t * table ) {
239
+ func (i indentedItem ) Emit (t * table ) {
240
240
subTable := t .indented ("" , i .depth )
241
241
i .tableContents .Emit (subTable )
242
242
t .addSection (subTable )
@@ -373,8 +373,9 @@ type table struct {
373
373
374
374
func (s * HistorySize ) TableString (
375
375
refGroups []RefGroup , threshold Threshold , nameStyle NameStyle ,
376
+ opts FormatOptions ,
376
377
) string {
377
- contents := s .contents (refGroups )
378
+ contents := s .contents (refGroups , opts )
378
379
t := table {
379
380
threshold : threshold ,
380
381
nameStyle : nameStyle ,
@@ -454,17 +455,20 @@ func (t *table) formatRow(
454
455
)
455
456
}
456
457
458
+ type FormatOptions struct {
459
+ WithoutReferenceCount bool
460
+ }
461
+
457
462
func (s * HistorySize ) JSON (
458
- refGroups []RefGroup , threshold Threshold , nameStyle NameStyle ,
459
- ) ([]byte , error ) {
460
- contents := s .contents (refGroups )
463
+ refGroups []RefGroup , threshold Threshold , nameStyle NameStyle , opts FormatOptions ) ([]byte , error ) {
464
+ contents := s .contents (refGroups , opts )
461
465
items := make (map [string ]* item )
462
466
contents .CollectItems (items )
463
467
j , err := json .MarshalIndent (items , "" , " " )
464
468
return j , err
465
469
}
466
470
467
- func (s * HistorySize ) contents (refGroups []RefGroup ) tableContents {
471
+ func (s * HistorySize ) contents (refGroups []RefGroup , opts FormatOptions ) tableContents {
468
472
S := newSection
469
473
I := newItem
470
474
metric := counts .Metric
@@ -489,6 +493,20 @@ func (s *HistorySize) contents(refGroups []RefGroup) tableContents {
489
493
rgis = append (rgis , rgi .Indented (indent ))
490
494
}
491
495
496
+ var refCountSection section
497
+ if ! opts .WithoutReferenceCount {
498
+ refCountSection = S (
499
+ "References" ,
500
+ I ("referenceCount" , "Count" ,
501
+ "The total number of references" ,
502
+ nil , s .ReferenceCount , metric , "" , 25e3 ),
503
+ S (
504
+ "" ,
505
+ rgis ... ,
506
+ ),
507
+ )
508
+ }
509
+
492
510
return S (
493
511
"" ,
494
512
S (
@@ -533,16 +551,7 @@ func (s *HistorySize) contents(refGroups []RefGroup) tableContents {
533
551
nil , s .UniqueTagCount , metric , "" , 25e3 ),
534
552
),
535
553
536
- S (
537
- "References" ,
538
- I ("referenceCount" , "Count" ,
539
- "The total number of references" ,
540
- nil , s .ReferenceCount , metric , "" , 25e3 ),
541
- S (
542
- "" ,
543
- rgis ... ,
544
- ),
545
- ),
554
+ refCountSection ,
546
555
),
547
556
548
557
S ("Biggest objects" ,
0 commit comments