Alpha: better spreading of roll storage

This greatly reduces the time spent reading roll, while it only
slightly increase the time spent while 'freezing' rolls at the end of
a cycle.
This commit is contained in:
Grégoire Henry 2017-11-19 21:30:48 +01:00 committed by Benjamin Canou
parent 485d8bc26a
commit 7bd5ef32d9

View File

@ -25,11 +25,10 @@ let (=) = Compare.Int32.(=)
module Index = struct module Index = struct
type t = roll type t = roll
let path_length = 3 let path_length = 3
let nbyte_of_int32 i n =
Int32.to_string @@
Int32.logand (Int32.shift_right i (8 * n)) (Int32.of_int 0xff)
let to_path roll l = let to_path roll l =
nbyte_of_int32 roll 0 :: nbyte_of_int32 roll 1 :: Int32.to_string roll :: l (Int32.to_string @@ Int32.logand roll (Int32.of_int 0xff)) ::
(Int32.to_string @@ Int32.logand (Int32.shift_right_logical roll 8) (Int32.of_int 0xff)) ::
Int32.to_string roll :: l
let of_path = function let of_path = function
| _ :: _ :: s :: _ -> begin | _ :: _ :: s :: _ -> begin
try Some (Int32.of_string s) try Some (Int32.of_string s)