# HG changeset patch # User Chris Cannam # Date 1409741371 -3600 # Node ID cf23656a8ca691ad17433a49b7740f45a287e1cf # Parent 0c993091a4c9e9e179c035597297f3387547b1fa Clarify some sneaky logic diff -r 0c993091a4c9 -r cf23656a8ca6 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Wed Sep 03 11:48:18 2014 +0100 +++ b/layer/TimeValueLayer.cpp Wed Sep 03 11:49:31 2014 +0100 @@ -733,13 +733,21 @@ i = close.begin(); // Scan through the close points first, then the more distant ones - // if no suitable close one is found + // if no suitable close one is found. So the while-termination + // condition here can only happen once i has passed through the + // whole of the close container and then the whole of the separate + // points container. The two iterators are totally distinct, but + // have the same type so we cheekily use the same variable and a + // single loop for both. while (i != points.end()) { - if (i == close.end()) { - i = points.begin(); - distant = true; + if (!distant) { + if (i == close.end()) { + // switch from the close container to the points container + i = points.begin(); + distant = true; + } } if (snap == SnapRight) {