From 526d33830029ec87b5087a49a095b554bfad9bf0 Mon Sep 17 00:00:00 2001 From: Matija Dizdar Date: Wed, 6 Dec 2023 21:29:18 +0100 Subject: [PATCH 1/2] removed incorrect requirement for key type to be ordered in binary_search_by --- core/slice/slice.odin | 1 - 1 file changed, 1 deletion(-) diff --git a/core/slice/slice.odin b/core/slice/slice.odin index 9722150a5bf..67e86bf4cfc 100644 --- a/core/slice/slice.odin +++ b/core/slice/slice.odin @@ -171,7 +171,6 @@ binary_search :: proc(array: $A/[]$T, key: T) -> (index: int, found: bool) @(require_results) binary_search_by :: proc(array: $A/[]$T, key: T, f: proc(T, T) -> Ordering) -> (index: int, found: bool) - where intrinsics.type_is_ordered(T) #no_bounds_check { // INVARIANTS: // - 0 <= left <= (left + size = right) <= len(array) From 843b2350eb11d61084c7af40f347b47eed8f98f0 Mon Sep 17 00:00:00 2001 From: Matija Dizdar Date: Wed, 6 Dec 2023 21:48:37 +0100 Subject: [PATCH 2/2] added #no_bounds_check back into binary_search_by --- core/slice/slice.odin | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/slice/slice.odin b/core/slice/slice.odin index 67e86bf4cfc..748bd28f7e0 100644 --- a/core/slice/slice.odin +++ b/core/slice/slice.odin @@ -170,8 +170,7 @@ binary_search :: proc(array: $A/[]$T, key: T) -> (index: int, found: bool) } @(require_results) -binary_search_by :: proc(array: $A/[]$T, key: T, f: proc(T, T) -> Ordering) -> (index: int, found: bool) -{ +binary_search_by :: proc(array: $A/[]$T, key: T, f: proc(T, T) -> Ordering) -> (index: int, found: bool) #no_bounds_check { // INVARIANTS: // - 0 <= left <= (left + size = right) <= len(array) // - f returns .Less for everything in array[:left]