From 7bd5ef32d95301ac7e658db76a3ca74f2d90cb3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sun, 19 Nov 2017 21:30:48 +0100 Subject: [PATCH] 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. --- src/proto/alpha/roll_repr.ml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/proto/alpha/roll_repr.ml b/src/proto/alpha/roll_repr.ml index 7dfbd6ff4..2ba94ea85 100644 --- a/src/proto/alpha/roll_repr.ml +++ b/src/proto/alpha/roll_repr.ml @@ -25,11 +25,10 @@ let (=) = Compare.Int32.(=) module Index = struct type t = roll 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 = - 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 | _ :: _ :: s :: _ -> begin try Some (Int32.of_string s)