cmp/report_slices.go
func coalesceInterveningIdentical(groups []diffStats, windowSize int) []diffStats {
	groups, groupsOrig := groups[:0], groups
	for i, ds := range groupsOrig {
		if len(groups) >= 2 && ds.NumDiff() > 0 {
			prev := &groups[len(groups)-2] // Unequal group
			curr := &groups[len(groups)-1] // Equal group
			next := &groupsOrig[i]         // Unequal group
			hadX, hadY := prev.NumRemoved > 0, prev.NumInserted > 0
			hasX, hasY := next.NumRemoved > 0, next.NumInserted > 0
			if ((hadX || hasX) && (hadY || hasY)) && curr.NumIdentical <= windowSize {
				*prev = (*prev).Append(*curr).Append(*next)
				groups = groups[:len(groups)-1] // Truncate off equal group
				continue
			}
		}
		groups = append(groups, ds)
	}
	return groups
}
func coalesceInterveningIdentical(groups []diffStats, windowSize int) []diffStats {
	groups, groupsOrig := groups[:0], groups
	for i, ds := range groupsOrig {
		if len(groups) >= 2 && ds.NumDiff() > 0 {
			prev := &groups[len(groups)-2] // Unequal group
			curr := &groups[len(groups)-1] // Equal group
			next := &groupsOrig[i]         // Unequal group
			hadX, hadY := prev.NumRemoved > 0, prev.NumInserted > 0
			hasX, hasY := next.NumRemoved > 0, next.NumInserted > 0
			if ((hadX || hasX) && (hadY || hasY)) && curr.NumIdentical <= windowSize {
				*prev = (*prev).Append(*curr).Append(*next)
				groups = groups[:len(groups)-1] // Truncate off equal group
				continue
			}
		}
		groups = append(groups, ds)
	}
	return groups
}
func coalesceInterveningIdentical ( groups [ ] diffStats , windowSize int ) [ ] diffStats { groups , groupsOrig := groups [ : 0 ] , groups for i , ds := range groupsOrig { if len ( groups ) >= 2 && ds . NumDiff ( ) > 0 { prev := & groups [ len ( groups ) - 2 ] // Unequal group curr := & groups [ len ( groups ) - 1 ] // Equal group next := & groupsOrig [ i ] // Unequal group hadX , hadY := prev . NumRemoved > 0 , prev . NumInserted > 0 hasX , hasY := next . NumRemoved > 0 , next . NumInserted > 0 if ( ( hadX || hasX ) && ( hadY || hasY ) ) && curr . NumIdentical <= windowSize { * prev = ( * prev ) . Append ( * curr ) . Append ( * next ) groups = groups [ : len ( groups ) - 1 ] // Truncate off equal group continue } } groups = append ( groups , ds ) } return groups }
// coalesceInterveningIdentical coalesces sufficiently short (<= windowSize)
// equal groups into adjacent unequal groups that currently result in a
// dual inserted/removed printout. This acts as a high-pass filter to smooth
// out high-frequency changes within the windowSize.
coalesceInterveningIdentical coalesces sufficiently short ( < = windowSize ) equal groups into adjacent unequal groups that currently result in a dual inserted / removed printout . This acts as a high - pass filter to smooth out high - frequency changes within the windowSize .