Commit 579d3202 authored by POTTIER Francois's avatar POTTIER Francois

Save a tiny bit of time by using unsafe array accesses in [InfiniteArray].

These accesses are really safe, the bounds check is performed by [ensure].
parent 30c64a88
......@@ -23,6 +23,7 @@ let rec new_length length i =
new_length (2 * length) i
let ensure a i =
assert (0 <= i);
let table = a.table in
let length = Array.length table in
if i >= length then begin
......@@ -33,17 +34,17 @@ let ensure a i =
let get a i =
ensure a i;
a.table.(i)
Array.unsafe_get a.table (i)
let set a i x =
ensure a i;
a.table.(i) <- x;
Array.unsafe_set a.table (i) x;
a.extent <- max (i + 1) a.extent
let update a i f =
ensure a i;
let x = a.table.(i) in
a.table.(i) <- f x;
Array.unsafe_set a.table (i) (f x);
a.extent <- max (i + 1) a.extent
let extent a =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment