mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-03-10 23:38:32 -04:00
use Bytes.extend (praise modernity!)
This commit is contained in:
parent
059528257a
commit
f229973ee3
1 changed files with 2 additions and 4 deletions
|
|
@ -49,7 +49,7 @@ let gen_of_array arr =
|
||||||
if !r = Array.length arr then None
|
if !r = Array.length arr then None
|
||||||
else (
|
else (
|
||||||
let x = arr.(!r) in
|
let x = arr.(!r) in
|
||||||
incr r;
|
incr r;
|
||||||
Some x
|
Some x
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -123,9 +123,7 @@ let read_all ic =
|
||||||
while true do
|
while true do
|
||||||
(* resize *)
|
(* resize *)
|
||||||
if !len = Bytes.length !buf then (
|
if !len = Bytes.length !buf then (
|
||||||
let buf' = Bytes.create (2* !len) in
|
buf := Bytes.extend !buf 0 !len;
|
||||||
Bytes.blit !buf 0 buf' 0 !len;
|
|
||||||
buf := buf'
|
|
||||||
);
|
);
|
||||||
assert (Bytes.length !buf > !len);
|
assert (Bytes.length !buf > !len);
|
||||||
let n = input ic !buf !len (Bytes.length !buf - !len) in
|
let n = input ic !buf !len (Bytes.length !buf - !len) in
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue