Skip to content

Commit

Permalink
Optimise Int32.unsigned_to_int on 64-bit (#10244)
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Mar 2, 2021
1 parent 685f14c commit a477306
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -82,6 +82,9 @@ Working version
- #10228: Better code-generation for inlined comparisons
(Stephen Dolan, review by Alain Frisch and Xavier Leroy)

- #10244: Optimise Int32.unsigned_to_int
(Fabian Hemmer, review by Stephen Dolan and Xavier Leroy)

### Standard library:

- #9533: Added String.starts_with and String.ends_with.
Expand Down
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 a477306

Please sign in to comment.