| 610 | } |
| 611 | |
| 612 | func (d *Differ) PlainReplace(a []string, alo int, ahi int, b []string, blo int, bhi int) (out []string, err error) { |
| 613 | if !(alo < ahi) || !(blo < bhi) { // assertion |
| 614 | return nil, errors.New("low greater than or equal to high") |
| 615 | } |
| 616 | // dump the shorter block first -- reduces the burden on short-term |
| 617 | // memory if the blocks are of very different sizes |
| 618 | if bhi-blo < ahi-alo { |
| 619 | out = d.Dump("+", b, blo, bhi) |
| 620 | out = append(out, d.Dump("-", a, alo, ahi)...) |
| 621 | } else { |
| 622 | out = d.Dump("-", a, alo, ahi) |
| 623 | out = append(out, d.Dump("+", b, blo, bhi)...) |
| 624 | } |
| 625 | return out, nil |
| 626 | } |
| 627 | |
| 628 | func (d *Differ) FancyReplace(a []string, alo int, ahi int, b []string, blo int, bhi int) (out []string, err error) { |
| 629 | // When replacing one block of lines with another, search the blocks |