# HG changeset patch # User Sascha L. Teichmann # Date 1409045283 -7200 # Node ID 1e8812b996bca02c7cf29feea18397f4e9f99471 # Parent 8eb25cbfe2427d6792257919d08e36e5567a1d22 Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time. diff -r 8eb25cbfe242 -r 1e8812b996bc artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Tue Aug 26 11:18:03 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Tue Aug 26 11:28:03 2014 +0200 @@ -393,20 +393,19 @@ int lo, int hi, Visitor visitor ) { - if (lo > hi) { - return; - } - int mid = (lo+hi)/2; - Station st = stations[mid]; - double station = st.getStation(); - if (station < a) { - recursiveFindStations(a, b, mid+1, hi, visitor); - } else if (station > b) { - recursiveFindStations(a, b, lo, mid-1, visitor); - } else { - recursiveFindStations(a, b, lo, mid-1, visitor); - visitor.visit(st); - recursiveFindStations(a, b, mid+1, hi, visitor); + while (lo <= hi) { + int mid = (lo+hi)/2; + Station st = stations[mid]; + double station = st.getStation(); + if (station < a) { + lo = mid+1; + } else if (station > b) { + hi = mid-1; + } else { + recursiveFindStations(a, b, lo, mid-1, visitor); + visitor.visit(st); + lo = mid+1; + } } }