From 31eb8d163fa63c6f7a7d58e63718f2d5fad71cdd Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 15 Mar 2026 03:25:54 +0000 Subject: [PATCH] format --- src/bencode/containers_bencode.ml | 4 ++-- src/core/CCHash.ml | 12 +++++++----- src/core/CCHash64.ml | 27 +++++++++++++++++++++------ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/bencode/containers_bencode.ml b/src/bencode/containers_bencode.ml index 3160ca59..c9c63ca7 100644 --- a/src/bencode/containers_bencode.ml +++ b/src/bencode/containers_bencode.ml @@ -23,8 +23,8 @@ let rec hash t = | List l -> H.combine2 20 (H.list hash l) | Map l -> H.combine2 30 - (H.iter (H.pair H.string hash) @@ fun k -> - Str_map.iter (fun x y -> k (x, y)) l) + ( H.iter (H.pair H.string hash) @@ fun k -> + Str_map.iter (fun x y -> k (x, y)) l ) let int64 i : t = Int i let int i : t = int64 (Int64.of_int i) diff --git a/src/core/CCHash.ml b/src/core/CCHash.ml index ef03010d..99078f04 100644 --- a/src/core/CCHash.ml +++ b/src/core/CCHash.ml @@ -7,7 +7,6 @@ type 'a t = 'a -> hash type 'a iter = ('a -> unit) -> unit type 'a gen = unit -> 'a option - let[@inline] combine2 a b = Hash_impl_.(finalize (combine_int (combine_int seed a) b)) @@ -56,7 +55,9 @@ let bool b = let char x = Hash_impl_.(finalize (combine_char seed (Char.code x))) let int64 (n : int64) : int = Hash_impl_.(finalize (combine_i64 seed n)) let int32 (x : int32) : int = Hash_impl_.(finalize (combine_i32 seed x)) -let nativeint (x : nativeint) = Hash_impl_.(finalize (combine_i64 seed (Int64.of_nativeint x))) + +let nativeint (x : nativeint) = + Hash_impl_.(finalize (combine_i64 seed (Int64.of_nativeint x))) let bytes (x : bytes) = Hash_impl_.(finalize (combine_string seed (Bytes.unsafe_to_string x))) @@ -76,8 +77,7 @@ let slice x i len = let opt f = function | None -> 42 - | Some x -> - Hash_impl_.(finalize (combine_int (combine_int seed 43) (f x))) + | Some x -> Hash_impl_.(finalize (combine_int (combine_int seed 43) (f x))) let list f l = let s = @@ -87,7 +87,9 @@ let list f l = let array f a = let s = - Array.fold_left (fun s x -> Hash_impl_.combine_int s (f x)) Hash_impl_.seed a + Array.fold_left + (fun s x -> Hash_impl_.combine_int s (f x)) + Hash_impl_.seed a in Hash_impl_.finalize s diff --git a/src/core/CCHash64.ml b/src/core/CCHash64.ml index d597cf95..79838e31 100644 --- a/src/core/CCHash64.ml +++ b/src/core/CCHash64.ml @@ -5,18 +5,27 @@ type state = int64 let seed : state = Hash_impl_.seed - let[@inline] finalize64 (s : state) : int64 = Hash_impl_.fmix64 s let[@inline] finalize (s : state) : int = Hash_impl_.finalize s type 'a t = state -> 'a -> state let[@inline] int s x = Hash_impl_.combine_int s x -let[@inline] bool s b = Hash_impl_.combine_int s (if b then 1 else 2) + +let[@inline] bool s b = + Hash_impl_.combine_int s + (if b then + 1 + else + 2) + let[@inline] char s c = Hash_impl_.combine_char s (Char.code c) let[@inline] int64 s (x : int64) = Hash_impl_.combine_i64 s x let[@inline] int32 s (x : int32) = Hash_impl_.combine_i32 s x -let[@inline] nativeint s (x : nativeint) = Hash_impl_.combine_i64 s (Int64.of_nativeint x) + +let[@inline] nativeint s (x : nativeint) = + Hash_impl_.combine_i64 s (Int64.of_nativeint x) + let[@inline] string s x = Hash_impl_.combine_string s x let[@inline] bytes s x = Hash_impl_.combine_string s (Bytes.unsafe_to_string x) @@ -26,7 +35,8 @@ let slice str ofs s len = if k = j then st else - loop (k + 1) (Hash_impl_.combine_char st (Char.code (String.unsafe_get str k))) + loop (k + 1) + (Hash_impl_.combine_char st (Char.code (String.unsafe_get str k))) in loop ofs s @@ -39,9 +49,14 @@ let array f s a = Array.fold_left f s a let pair f g s (x, y) = g (f s x) y let triple f g h s (x, y, z) = h (g (f s x) y) z let quad f g h k s (x, y, z, w) = k (h (g (f s x) y) z) w - let map proj f s x = f s (proj x) -let if_ b then_ else_ s x = if b then then_ s x else else_ s x + +let if_ b then_ else_ s x = + if b then + then_ s x + else + else_ s x + let poly s x = Hash_impl_.combine_int s (Hashtbl.hash x) type 'a iter = ('a -> unit) -> unit