From dda21ec7d1bee229c3e5af80fa06162735a74cb7 Mon Sep 17 00:00:00 2001 From: Xinok Date: Sun, 29 Nov 2015 16:16:54 -0600 Subject: [PATCH] Issue 15385 --- std/range/package.d | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/std/range/package.d b/std/range/package.d index 01405e51f3e..0e44dd8ef79 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -7833,28 +7833,10 @@ sgi.com/tech/stl/binary_search.html, binary_search). bool contains(V)(V value) if (isRandomAccessRange!Range) { - size_t first = 0, count = _input.length; - while (count > 0) - { - immutable step = count / 2, it = first + step; - if (predFun(_input[it], value)) - { - // Less than value, bump left bound up - first = it + 1; - count -= step + 1; - } - else if (predFun(value, _input[it])) - { - // Greater than value, chop count - count = step; - } - else - { - // Found!!! - return true; - } - } - return false; + if(empty) return false; + immutable i = getTransitionIndex!(SearchPolicy.binarySearch, geq)(value); + if(i >= length) return false; + return !predFun(value, _input[i]); } // groupBy