Skip to content

Commit 4a4925f

Browse files
committed
adding a succ to prepare optimize Int64.succ
1 parent fbc8890 commit 4a4925f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

jscomp/runtime/caml_int64.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ let neg_one = mk ~lo:(-1n) ~hi:(-1n)
7272

7373
let neg_signed x = (x & 0x8000_0000n) <> 0n
7474

75+
let succ_aux ~x_lo ~x_hi =
76+
let lo = ( x_lo +~ 1n) & 0xffff_ffffn in
77+
mk ~lo ~hi:(( x_hi +~ if lo = 0n then 1n else 0n) & 0xffff_ffffn)
78+
let succ (Int64 {lo = x_lo; hi = x_hi} : t) =
79+
succ_aux ~x_lo ~x_hi
80+
7581
let neg (Int64 {lo;hi} ) =
7682
let other_lo = (lognot lo +~ 1n) & 0xffff_ffffn in
7783
mk ~lo:other_lo

0 commit comments

Comments
 (0)