This PR gets rid of any unnecessary computations in Product2.distance(from:to:). In particular, it now only does a single pass over base2 in the worst case (instead of 3), and for non-random-access collections it no longer does more index calculations than the default implementation of distance(from:to:).
Checklist
[x] I've added at least one test that validates that my change is working, if appropriate
[x] I've followed the code style of the rest of the project
This PR gets rid of any unnecessary computations in
Product2.distance(from:to:)
. In particular, it now only does a single pass overbase2
in the worst case (instead of 3), and for non-random-access collections it no longer does more index calculations than the default implementation ofdistance(from:to:)
.Checklist