Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid throwing an exception when sorting identical paths (#90)
Fixes #44 The basic issue is that our loops `i` is being incremented and fed into `getSegment` before the out-of-bounds check. Thus if two paths are identical, it ends up overshooting the end of the sequence of segments, resulting in the error reported. The fix is to order the `i += 1` such that it takes place immediately before the out-of-bounds check, to ensure it is always in bounds when we pass it to `getSegment` The `i == xSegCount` check at the bottom was also incorrect. Just because we've hit the end of the list doesn't mean the two paths are equal, as the point of the loop is to find the first non-equal string segment so we can compare them. Thus we should compare the two string segments every time: if they are equal and we haven't run out, we loop another time, otherwise we return the result of the comparison Adds a test case that reproduces the failure on master, passes on this PR Review by @lefou
- Loading branch information