From 2827011b37dd3ae02a6a6857340bc580a104218e Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 17 Feb 2026 02:19:04 +0000 Subject: [PATCH] ocamlformat --- benchs/run_benchs.ml | 7 ++----- src/core/CCInt.ml | 3 ++- src/core/CCInt64.ml | 3 ++- tests/core/t_int64.ml | 12 +++++++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/benchs/run_benchs.ml b/benchs/run_benchs.ml index 380183b5..9a6d6f3c 100644 --- a/benchs/run_benchs.ml +++ b/benchs/run_benchs.ml @@ -1830,7 +1830,7 @@ module Hash = struct let prime = 0x100000001b3L in let h = ref offset_basis in for k = 0 to 7 do - h := Int64.(mul !h prime); + (h := Int64.(mul !h prime)); h := Int64.(logxor !h (of_int ((n lsr (k * 8)) land 0xff))) done; Int64.to_int !h land max_int @@ -1846,10 +1846,7 @@ module Hash = struct done in B.throughputN 3 ~repeat - [ - "ocaml_fnv", run_ocaml, (); - "c_stub", run_c_stub, (); - ] + [ "ocaml_fnv", run_ocaml, (); "c_stub", run_c_stub, () ] let () = B.Tree.register ("hash" @>>> [ "int" @>> app_ints bench_hash [ 1_000 ] ]) diff --git a/src/core/CCInt.ml b/src/core/CCInt.ml index 016caf69..c9a6115e 100644 --- a/src/core/CCInt.ml +++ b/src/core/CCInt.ml @@ -7,7 +7,8 @@ type 'a iter = ('a -> unit) -> unit (* use FNV-1: https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function *) external hash : (int[@untagged]) -> (int[@untagged]) - = "caml_cc_hash_int_byte" "caml_cc_hash_int" [@@noalloc] + = "caml_cc_hash_int_byte" "caml_cc_hash_int" +[@@noalloc] let range i j yield = let rec up i j yield = diff --git a/src/core/CCInt64.ml b/src/core/CCInt64.ml index 0c3f2405..5d32c602 100644 --- a/src/core/CCInt64.ml +++ b/src/core/CCInt64.ml @@ -17,7 +17,8 @@ external hash_to_int64 : (int64[@unboxed]) -> (int64[@unboxed]) = "caml_cc_hash_int64_to_int64_byte" "caml_cc_hash_int64_to_int64" external hash : (int64[@unboxed]) -> (int[@untagged]) - = "caml_cc_hash_int64_byte" "caml_cc_hash_int64" [@@noalloc] + = "caml_cc_hash_int64_byte" "caml_cc_hash_int64" +[@@noalloc] (* see {!CCInt.popcount} for more details *) let[@inline] popcount (b : t) : int = diff --git a/tests/core/t_int64.ml b/tests/core/t_int64.ml index 64d27bd9..c958520c 100644 --- a/tests/core/t_int64.ml +++ b/tests/core/t_int64.ml @@ -103,8 +103,8 @@ eq' 10 (popcount 0b1110010110110001010L);; eq' 5 (popcount 0b1101110000000000L) (* hash tests *) -let ( >= ) = Stdlib.( >= );; -let ( = ) = Stdlib.( = );; +let ( >= ) = Stdlib.( >= ) +let ( = ) = Stdlib.( = ) let ( <> ) = Stdlib.( <> );; (* hash is non-negative *) @@ -120,10 +120,12 @@ t @@ fun () -> CCInt64.compare (hash_to_int64 (-1L)) 0L >= 0;; t @@ fun () -> CCInt64.compare (hash_to_int64 min_int) 0L >= 0;; (* hash is consistent with hash_to_int64 *) +t @@ fun () -> hash 42L = Stdlib.(Int64.to_int (hash_to_int64 42L) land max_int) +;; + t @@ fun () -> - hash 42L = Stdlib.(Int64.to_int (hash_to_int64 42L) land max_int);; -t @@ fun () -> - hash (-1L) = Stdlib.(Int64.to_int (hash_to_int64 (-1L)) land max_int);; +hash (-1L) = Stdlib.(Int64.to_int (hash_to_int64 (-1L)) land max_int) +;; (* different inputs produce different hashes *) t @@ fun () -> hash 0L <> hash 1L;;