Skip to content

Commit bd89614

Browse files
committed
1 parent 9c5f580 commit bd89614

16 files changed

+388
-84
lines changed

jscomp/all.depend

+3-3
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ core/js_number.cmi :
246246
core/js_cmj_datasets.cmi : ext/string_map.cmi core/js_cmj_format.cmi
247247
core/lam_exit_code.cmi : core/lam.cmi
248248
core/lam_module_ident.cmi : core/js_op.cmx common/js_config.cmi core/j.cmx \
249-
ext/hashtbl_gen.cmx
249+
ext/hashtbl_gen.cmx ext/hash_set_gen.cmx
250250
core/lam_compile_util.cmi : core/js_op.cmx
251251
core/lam_stats.cmi : core/lam_module_ident.cmi core/lam.cmi \
252252
ext/int_hash_set.cmi ext/ident_set.cmi ext/ident_hashtbl.cmi
@@ -350,8 +350,8 @@ core/lam_exit_code.cmx : core/lam.cmx core/lam_exit_code.cmi
350350
core/j.cmx : core/js_op.cmx core/js_fun_env.cmx core/js_closure.cmx \
351351
core/js_call_info.cmx ext/ident_set.cmx
352352
core/lam_module_ident.cmx : core/js_op.cmx common/js_config.cmx core/j.cmx \
353-
ext/hashtbl_make.cmx ext/ext_ident.cmx stubs/bs_hash_stubs.cmx \
354-
core/lam_module_ident.cmi
353+
ext/hashtbl_make.cmx ext/hash_set.cmx ext/ext_ident.cmx \
354+
stubs/bs_hash_stubs.cmx core/lam_module_ident.cmi
355355
core/lam_compile_util.cmx : core/js_op.cmx core/lam_compile_util.cmi
356356
core/lam_stats.cmx : core/lam_module_ident.cmx core/lam.cmx \
357357
ext/int_hash_set.cmx ext/ident_set.cmx ext/ident_hashtbl.cmx \

jscomp/bin/all_ounit_tests.ml

+29
Original file line numberDiff line numberDiff line change
@@ -4981,6 +4981,14 @@ module type S = sig
49814981
val find_exn: 'a t -> key -> 'a
49824982
val find_all: 'a t -> key -> 'a list
49834983
val find_opt: 'a t -> key -> 'a option
4984+
4985+
(** return the key found in the hashtbl.
4986+
Use case: when you find the key existed in hashtbl,
4987+
you want to use the one stored in the hashtbl.
4988+
(they are semantically equivlanent, but may have other information different)
4989+
*)
4990+
val find_key_opt: 'a t -> key -> key option
4991+
49844992
val find_default: 'a t -> key -> 'a -> 'a
49854993

49864994
val replace: 'a t -> key -> 'a -> unit
@@ -5124,6 +5132,23 @@ let rec small_bucket_opt eq key (lst : _ bucketlist) : _ option =
51245132
if eq key k3 then Some d3 else
51255133
small_bucket_opt eq key rest3
51265134

5135+
5136+
let rec small_bucket_key_opt eq key (lst : _ bucketlist) : _ option =
5137+
match lst with
5138+
| Empty -> None
5139+
| Cons(k1,d1,rest1) ->
5140+
if eq key k1 then Some k1 else
5141+
match rest1 with
5142+
| Empty -> None
5143+
| Cons(k2,d2,rest2) ->
5144+
if eq key k2 then Some k2 else
5145+
match rest2 with
5146+
| Empty -> None
5147+
| Cons(k3,d3,rest3) ->
5148+
if eq key k3 then Some k3 else
5149+
small_bucket_key_opt eq key rest3
5150+
5151+
51275152
let rec small_bucket_default eq key default (lst : _ bucketlist) =
51285153
match lst with
51295154
| Empty -> default
@@ -5258,6 +5283,10 @@ let find_exn (h : _ t) key =
52585283

52595284
let find_opt (h : _ t) key =
52605285
Hashtbl_gen.small_bucket_opt eq_key key (Array.unsafe_get h.data (key_index h key))
5286+
5287+
let find_key_opt (h : _ t) key =
5288+
Hashtbl_gen.small_bucket_key_opt eq_key key (Array.unsafe_get h.data (key_index h key))
5289+
52615290
let find_default (h : _ t) key default =
52625291
Hashtbl_gen.small_bucket_default eq_key key default (Array.unsafe_get h.data (key_index h key))
52635292
let find_all (h : _ t) key =

jscomp/bin/whole_compiler.d

+2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ bin/whole_compiler.ml : ext/ident_map.ml
198198
bin/whole_compiler.ml : ext/ident_map.mli
199199
bin/whole_compiler.ml : core/lam_analysis.ml
200200
bin/whole_compiler.ml : core/lam_analysis.mli
201+
bin/whole_compiler.ml : ext/hash_set.ml
202+
bin/whole_compiler.ml : ext/hash_set.mli
201203
bin/whole_compiler.ml : ext/hashtbl_make.ml
202204
bin/whole_compiler.ml : ext/hashtbl_make.mli
203205
bin/whole_compiler.ml : core/lam_module_ident.ml

0 commit comments

Comments
 (0)