Skip to content

Commit

Permalink
Optimise Int32.unsigned_to_int on 64-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Feb 23, 2021
1 parent 000564e commit e8250b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stdlib/int32.ml
Expand Up @@ -63,8 +63,8 @@ let unsigned_to_int =
None
| 64 ->
(* So that it compiles in 32-bit *)
let move = int_of_string "0x1_0000_0000" in
fun n -> let i = to_int n in Some (if i < 0 then i + move else i)
let mask = 0xFFFF lsl 16 lor 0xFFFF in
fun n -> Some (to_int n land mask)
| _ ->
assert false

Expand Down

0 comments on commit e8250b6

Please sign in to comment.