Make int_compare avoid overflow

Summary:
Change int_compare to avoid overflow, without generating a call to a C
function or any branch instructions.

Reviewed By: cristianoc

Differential Revision: D3417671

fbshipit-source-id: e4c5d7b
master
Josh Berdine 9 years ago committed by Facebook Github Bot 5
parent def747814a
commit 3828bdd544

@ -56,7 +56,7 @@ let opt_compare cmp x1 x2 =
| _, None -> 1
(** Efficient comparison for integers *)
let int_compare (i: int) (j: int) = i - j
let int_compare (i: int) (j: int) = (Obj.magic (i > j)) - (Obj.magic (i < j))
let int_equal (i: int) (j: int) = i = j

Loading…
Cancel
Save