// If the lines immediately before those in the block move are identical, // then grow the block move by one and repeat. func GrowBackwards(p *dm.BlockMatch, aLines, bLines []dm.LinePos) { glog.Infof("GrowBackwards: dm.BlockMatch = %v", *p) aLimit, bLimit := aLines[0].Index, bLines[0].Index glog.Infof("GrowBackwards aLimit=%d, bLimit=%d", aLimit, bLimit) a := findLineWithIndex(aLines, p.AIndex) b := findLineWithIndex(bLines, p.BIndex) glog.Infof("GrowBackwards a=%d, b=%d", a, b) if aLines[a].Hash != bLines[b].Hash { glog.Fatalf("GrowBackwards: Lines %d and %d should have the same hash", a, b) } growBy := 0 for a > aLimit && b > bLimit { a-- b-- if aLines[a].Hash != bLines[b].Hash { break } growBy++ } glog.Infof("GrowBackwards growBy=%d", growBy) p.AIndex -= growBy p.BIndex -= growBy p.Length += growBy }