Check-in [e01b36769d]
Overview
Comment: Skip diagonals shorter than the current match Tarball | ZIP archive | SQL archive family | ancestors | descendants | both | files | file ages | folders e01b36769d02f7299edb71b084bb4aad79f95cdf spaskalev on 2014-12-14 12:11:19 manifest | tags
Context
 2014-12-14 20:41 Buffer stdout, use os.Args instead of flag check-in: 074a26f76b user: spaskalev tags: trunk 12:11 Skip diagonals shorter than the current match check-in: e01b36769d user: spaskalev tags: trunk 01:03 [bits] fixed package documentation [bits] added tests for the bool-backed vector [diff] added a real test, commented out the visual debug aids [plaindiff] added comments, removed commented code, added a helper []line getter [math] removed math package as it is currently unused check-in: d5adabf68e user: spaskalev tags: trunk
Changes

Modified src/0dev.org/diff/diff.go from [bb37f97581] to [1f071ca8dd].

```    88     88
89     89   	return result
90     90   }
91     91
92     92   // Finds the largest common substring by looking at the provided match matrix
93     93   // starting from (bounds.x, bounds.y) with lengths bounds.lenX, bounds.lenY
94     94   func largest(bounds box, mat matrix) (result match) {
95         -	for i := bounds.x; i < bounds.lenX; i++ {
95  +	for i := bounds.x; i < bounds.lenX && result.length <= (bounds.lenX-bounds.x); i++ {
96     96   		var m match = search(i, bounds.y, bounds.lenX, bounds.lenY, mat)
97     97   		if m.length > result.length {
98     98   			result = m
99     99   		}
100    100   	}
101         -	for j := bounds.y + 1; j < bounds.lenY; j++ {
101  +	for j := bounds.y + 1; j < bounds.lenY && result.length <= (bounds.lenY-bounds.y); j++ {
102    102   		var m match = search(bounds.x, j, bounds.lenX, bounds.lenY, mat)
103    103   		if m.length > result.length {
104    104   			result = m
105    105   		}
106    106   	}
107    107   	return
108    108   }

```