138
138
139
139
module Internalhash : sig
140
140
include Hash_intf. S
141
- with type state = private int (* allow optimizations for immediate type *)
142
- and type seed = int
143
- and type hash_value = int
141
+ with type state = Base_internalhash_types. state
142
+ (* We give a concrete type for [state], albeit only partially exposed (see
143
+ Base_internalhash_types), so that it unifies with the same type in [Base_boot],
144
+ and to allow optimizations for the immediate type. *)
145
+ and type seed = Base_internalhash_types. seed
146
+ and type hash_value = Base_internalhash_types. hash_value
144
147
145
148
external fold_int64 : state -> int64 -> state = " Base_internalhash_fold_int64" [@@ noalloc]
146
149
external fold_int : state -> int -> state = " Base_internalhash_fold_int" [@@ noalloc]
@@ -150,24 +153,15 @@ module Internalhash : sig
150
153
end = struct
151
154
let description = " internalhash"
152
155
153
- type state = int
154
- type hash_value = int
155
- type seed = int
156
-
157
- external create_seeded : seed -> state = "%identity" [@@ noalloc]
158
- external fold_int64 : state -> int64 -> state = "Base_internalhash_fold_int64" [@@ noalloc]
159
- external fold_int : state -> int -> state = "Base_internalhash_fold_int" [@@ noalloc]
160
- external fold_float : state -> float -> state = "Base_internalhash_fold_float" [@@ noalloc]
161
- external fold_string : state -> string -> state = "Base_internalhash_fold_string" [@@ noalloc]
162
- external get_hash_value : state -> hash_value = "Base_internalhash_get_hash_value" [@@ noalloc]
156
+ include Base_internalhash_types
163
157
164
158
let alloc () = create_seeded 0
165
159
166
160
let reset ?(seed =0 ) _t = create_seeded seed
167
161
168
162
module For_tests = struct
169
- let compare_state = compare
170
- let state_to_string = Int. to_string
163
+ let compare_state ( a : state ) ( b : state ) = compare (a :> int ) (b :> int )
164
+ let state_to_string ( state : state ) = Int. to_string (state :> int )
171
165
end
172
166
end
173
167
0 commit comments