1. Dmitry Grebeniuk
  2. ocaml-iteratees

Commits

Dmitry Grebeniuk  committed 9df36ef

array resizing for utf: to powers of 2

  • Participants
  • Parent commits bf5d96d
  • Branches default

Comments (0)

Files changed (1)

File iteratees.ml

View file
 
 value array_ensure_size ~default array_ref size =
   let realloc () =
-    let r = Array.make size default in
+    let new_size =
+      loop 1
+      where rec loop n =
+        if n < size
+        then loop (n * 2)
+        else n
+    in
+    let r = Array.make new_size default in
     ( array_ref.val := r
     ; r
     )