Closed perlfly closed 8 years ago
I admit that my guard changes look a bit ugly. Reasons why I proposed a change are:
d
matrix (a marginal memory optimisation)Maybe I'll try another solution for moving up the guards. Please, if I do, don't consider it as me trying to force that change ... just reasoning about it and open to your opinions.
While I’d definitely like to exit earlier, the value of the only slightly earlier exist was not justified by the duplicated code and marginal memory optimisation, in my opinion.
The for
loops come quite early – after the d
allocation, yes, but it only allocates the amount of memory needed anyway. Just like your code.
A much more relevant optimisation, I think, would be to make the Changeset.edits
property lazy
. The user may have a bunch of Changeset
values in the air, and may only be querying the edits
on some of those. It would be a waste to have computed the edit distances in those unused cases. But I haven’t found a way to do that in Swift 2.
:+1: Thanks
Remove force cast to Int adding Generic constraint for CollectionType Move guard conditions in
editDistance
at the top of the function