Merge pull request 'Add the shift function on Bstr' (#5) from shift into main

Reviewed-on: #5
This commit is contained in:
dinosaure 2025-01-13 12:43:29 +00:00
commit dece77fd2c
2 changed files with 8 additions and 0 deletions

View file

@ -391,6 +391,11 @@ module Bstr = struct
match rev with match rev with
| true -> rdrop ?min ?max ?sat bstr | true -> rdrop ?min ?max ?sat bstr
| false -> fdrop ?min ?max ?sat bstr | false -> fdrop ?min ?max ?sat bstr
let shift bstr off =
if off > length bstr then invalid_arg "Cachet.Bstr.shift";
let len = length bstr - off in
Bigarray.Array1.sub bstr off len
end end
external hash : (int32[@unboxed]) -> int -> (int32[@unboxed]) external hash : (int32[@unboxed]) -> int -> (int32[@unboxed])

View file

@ -187,6 +187,9 @@ module Bstr : sig
{[ {[
(if rev then fst else snd) @@ span ~rev ~min ~max ~sat bstr (if rev then fst else snd) @@ span ~rev ~min ~max ~sat bstr
]} *) ]} *)
val shift : t -> int -> t
(** [shift bstr n] is [sub bstr n (length bstr - n)]. *)
end end
type slice = private { offset: int; length: int; payload: Bstr.t } type slice = private { offset: int; length: int; payload: Bstr.t }