fix: rename size to cap in CCByte_buffer

This commit is contained in:
Simon Cruanes 2022-02-08 11:43:26 -05:00
parent 5f064dbbbf
commit b42b1f4907
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 7 additions and 6 deletions

View file

@ -5,10 +5,10 @@ type t = {
mutable sz: int;
}
let create ?(size=0) () : t =
let create ?(cap=0) () : t =
let bytes =
if size=0 then Bytes.unsafe_of_string "" else Bytes.create size in
{ sz=size; bytes }
if cap=0 then Bytes.unsafe_of_string "" else Bytes.create cap in
{ sz=0; bytes }
let[@inline] capacity self : int = Bytes.length self.bytes
let[@inline] bytes self = self.bytes
@ -95,12 +95,12 @@ let iter f self =
done
let of_seq seq =
let self = create ~size:32 () in
let self = create ~cap:32 () in
append_seq self seq;
self
let of_iter iter =
let self = create ~size:32 () in
let self = create ~cap:32 () in
append_iter self iter;
self

View file

@ -9,7 +9,8 @@ type t
type 'a iter = ('a -> unit) -> unit
val create : ?size:int -> unit -> t
val create : ?cap:int -> unit -> t
(** Create a new buffer with given initial capacity. *)
val length : t -> int
(** Current length. *)