cmp/report_compare.go
func coalesceAdjacentRecords(name string, recs []reportRecord) (groups []diffStats) {
	var prevCase int // Arbitrary index into which case last occurred
	lastStats := func(i int) *diffStats {
		if prevCase != i {
			groups = append(groups, diffStats{Name: name})
			prevCase = i
		}
		return &groups[len(groups)-1]
	}
	for _, r := range recs {
		switch rv := r.Value; {
		case rv.NumIgnored > 0 && rv.NumSame+rv.NumDiff == 0:
			lastStats(1).NumIgnored++
		case rv.NumDiff == 0:
			lastStats(1).NumIdentical++
		case rv.NumDiff > 0 && !rv.ValueY.IsValid():
			lastStats(2).NumRemoved++
		case rv.NumDiff > 0 && !rv.ValueX.IsValid():
			lastStats(2).NumInserted++
		default:
			lastStats(2).NumModified++
		}
	}
	return groups
}
func coalesceAdjacentRecords(name string, recs []reportRecord) (groups []diffStats) {
	var prevCase int // Arbitrary index into which case last occurred
	lastStats := func(i int) *diffStats {
		if prevCase != i {
			groups = append(groups, diffStats{Name: name})
			prevCase = i
		}
		return &groups[len(groups)-1]
	}
	for _, r := range recs {
		switch rv := r.Value; {
		case rv.NumIgnored > 0 && rv.NumSame+rv.NumDiff == 0:
			lastStats(1).NumIgnored++
		case rv.NumDiff == 0:
			lastStats(1).NumIdentical++
		case rv.NumDiff > 0 && !rv.ValueY.IsValid():
			lastStats(2).NumRemoved++
		case rv.NumDiff > 0 && !rv.ValueX.IsValid():
			lastStats(2).NumInserted++
		default:
			lastStats(2).NumModified++
		}
	}
	return groups
}
func coalesceAdjacentRecords ( name string , recs [ ] reportRecord ) ( groups [ ] diffStats ) { var prevCase int // Arbitrary index into which case last occurred lastStats := func ( i int ) * diffStats { if prevCase != i { groups = append ( groups , diffStats { Name : name } ) prevCase = i } return & groups [ len ( groups ) - 1 ] } for _ , r := range recs { switch rv := r . Value ; { case rv . NumIgnored > 0 && rv . NumSame + rv . NumDiff == 0 : lastStats ( 1 ) . NumIgnored ++ case rv . NumDiff == 0 : lastStats ( 1 ) . NumIdentical ++ case rv . NumDiff > 0 && ! rv . ValueY . IsValid ( ) : lastStats ( 2 ) . NumRemoved ++ case rv . NumDiff > 0 && ! rv . ValueX . IsValid ( ) : lastStats ( 2 ) . NumInserted ++ default : lastStats ( 2 ) . NumModified ++ } } return groups }
// coalesceAdjacentRecords coalesces the list of records into groups of
// adjacent equal, or unequal counts.
coalesceAdjacentRecords coalesces the list of records into groups of adjacent equal or unequal counts .