package eqaf
Constant-time equal function on string
Install
Dune Dependency
Authors
Maintainers
Sources
eqaf-v0.4.tbz
sha256=754f9bafabd11d2e7c1ec0cfa1e045e221eee60239c537471db0892416524b81
sha512=2892d2dbe738f0e6833e3e6343978807a9a700388014681c879933f7a937ec8a3ee4a8e80ac4eaab80b502fd8ac7698270dbdefb9c05b79dd2463c86d11ff31b
doc/src/eqaf.bigstring/eqaf_bigstring.ml.html
Source file eqaf_bigstring.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t let length x = Bigarray.Array1.dim x [@@inline] let get x i = Bigarray.Array1.unsafe_get x i |> Char.code [@@inline] external unsafe_get_int16 : bigstring -> int -> int = "%caml_bigstring_get16u" [@@noalloc] let get16 x i = unsafe_get_int16 x i [@@inline] let equal ~ln a b = let l1 = ln asr 1 in let r = ref 0 in for i = 0 to pred l1 do r := !r lor (get16 a (i * 2) lxor get16 b (i * 2)) done ; for _ = 1 to ln land 1 do r := !r lor (get a (ln - 1) lxor get b (ln - 1)) done ; !r = 0 let[@inline] min (a:int) b = if a < b then a else b let equal a b = let al = length a in let bl = length b in let ln = min al bl in if (al lxor ln) lor (bl lxor ln) <> 0 then false else equal ~ln a b
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>