Bug 998507 - add some assertions to BinarySearch (r=me)
authorLuke Wagner <luke@mozilla.com>
Tue, 22 Apr 2014 13:53:37 -0500
changeset 179626 139c2e8c264ff015779ca62b87b81f41396542be
parent 179625 098f943ba58dcddc8e469f8ecf430998d1ef1d69
child 179627 418c50532eea49db1b765db1db23bac93403ac08
push id26632
push userkwierso@gmail.com
push dateWed, 23 Apr 2014 00:54:42 +0000
treeherdermozilla-central@02515cf4fcfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs998507
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 998507 - add some assertions to BinarySearch (r=me)
mfbt/BinarySearch.h
--- a/mfbt/BinarySearch.h
+++ b/mfbt/BinarySearch.h
@@ -37,16 +37,20 @@ BinarySearch(const Container &c, size_t 
   MOZ_ASSERT(begin <= end);
 
   size_t low = begin;
   size_t high = end;
   while (low != high) {
     size_t middle = low + (high - low) / 2;
     const T &middleValue = c[middle];
 
+    MOZ_ASSERT(c[low] <= c[middle]);
+    MOZ_ASSERT(c[middle] <= c[high - 1]);
+    MOZ_ASSERT(c[low] <= c[high - 1]);
+
     if (target == middleValue) {
       *matchOrInsertionPoint = middle;
       return true;
     }
 
     if (target < middleValue)
       high = middle;
     else