mirror of
https://github.com/c-cube/iter.git
synced 2025-12-06 11:15:32 -05:00
Implement suggested change (risky Cons {a;n;tl} -> Cons r)
This commit is contained in:
parent
3f14750a3b
commit
5b651084f6
1 changed files with 6 additions and 6 deletions
12
src/Iter.ml
12
src/Iter.ml
|
|
@ -204,7 +204,7 @@ module MList = struct
|
||||||
| _ ->
|
| _ ->
|
||||||
match !tail with
|
match !tail with
|
||||||
| Nil -> ()
|
| Nil -> ()
|
||||||
| Cons (_ as r) -> r.tl <- !cur
|
| Cons r -> r.tl <- !cur
|
||||||
in
|
in
|
||||||
|
|
||||||
seq (fun x ->
|
seq (fun x ->
|
||||||
|
|
@ -215,11 +215,11 @@ module MList = struct
|
||||||
let n = !chunk_size in
|
let n = !chunk_size in
|
||||||
if n < 4096 then chunk_size := 2 * n;
|
if n < 4096 then chunk_size := 2 * n;
|
||||||
cur := Cons {a=Array.make n x; n = 1; tl = Nil}
|
cur := Cons {a=Array.make n x; n = 1; tl = Nil}
|
||||||
| Cons ({a; n; tl} as r) ->
|
| Cons r ->
|
||||||
assert (n < Array.length a);
|
assert (r.n < Array.length r.a);
|
||||||
a.(n) <- x;
|
r.a.(r.n) <- x;
|
||||||
r.n <- succ n;
|
r.n <- succ r.n;
|
||||||
if r.n = Array.length a then (
|
if r.n = Array.length r.a then (
|
||||||
replace_tail ();
|
replace_tail ();
|
||||||
tail := !cur;
|
tail := !cur;
|
||||||
cur := Nil
|
cur := Nil
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue