From b4d5b8137c132db554ec9ed3644ebaf2988b7cba Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 3 Jul 2013 20:38:33 -0700 Subject: [PATCH] One step towards fixing this. We need asserts and logging. --- modules/ripple_basics/containers/ripple_RangeSet.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/ripple_basics/containers/ripple_RangeSet.cpp b/modules/ripple_basics/containers/ripple_RangeSet.cpp index 0bd84ffa3e..c46e9fde80 100644 --- a/modules/ripple_basics/containers/ripple_RangeSet.cpp +++ b/modules/ripple_basics/containers/ripple_RangeSet.cpp @@ -78,15 +78,18 @@ uint32 RangeSet::getPrev (uint32 v) const uint32 RangeSet::prevMissing (uint32 v) const { // largest number not in the set that is less than the given number + if (v == 0) + return absent; + BOOST_REVERSE_FOREACH (const value_type & it, mRanges) { - if (contains (it, v)) - return (it.first == 0) ? absent : (it.first - 1); - if (it.second < (v - 1)) return v - 1; + if (it.first >= v) + return (it.first == 0) ? absent : (it.first - 1); } - return absent; + + return v - 1; } void RangeSet::setValue (uint32 v)