Factored out parts of the diffing algorithm.

Edit length calculation is a separate component. Modification detection no
longer knows about diagonals.

Flow of information between the components is a bit clearer. Fewer
parameters to recursive functions might affect performance too.