Skip to content

Commit efacdc1

Browse files
committed
consistent naming of data collections
1 parent b692f6b commit efacdc1

File tree

188 files changed

+7910
-7864
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+7910
-7864
lines changed

.gitignore

+14-15
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,22 @@ bin/ninja.exe
115115
tmp/
116116
jscomp/ext/hash_set.ml
117117
jscomp/ext/hash_set_poly.ml
118-
jscomp/ext/hashtbl_make.ml
119-
jscomp/ext/ident_hash_set.ml
120-
jscomp/ext/ident_hashtbl.ml
121-
jscomp/ext/ident_map.ml
122-
jscomp/ext/ident_set.ml
123-
jscomp/ext/int_hash_set.ml
124-
jscomp/ext/int_hashtbl.ml
125-
jscomp/ext/int_map.ml
126-
jscomp/ext/int_vec.ml
118+
jscomp/ext/hash.ml
119+
jscomp/ext/hash_set_ident.ml
120+
jscomp/ext/hash_ident.ml
121+
jscomp/ext/map_ident.ml
122+
jscomp/ext/set_ident.ml
123+
jscomp/ext/hash_set_int.ml
124+
jscomp/ext/hash_int.ml
125+
jscomp/ext/map_int.ml
126+
jscomp/ext/vec_int.ml
127127
jscomp/ext/ordered_hash_map_local_ident.ml
128-
jscomp/ext/ordered_hash_set_make.ml
129-
jscomp/ext/resize_array.ml
128+
jscomp/ext/vec.ml
130129
jscomp/ext/set_int.ml
131-
jscomp/ext/string_hash_set.ml
132-
jscomp/ext/string_hashtbl.ml
133-
jscomp/ext/string_map.ml
134-
jscomp/ext/string_set.ml
130+
jscomp/ext/hash_set_string.ml
131+
jscomp/ext/hash_string.ml
132+
jscomp/ext/map_string.ml
133+
jscomp/ext/set_string.ml
135134
jscomp/syntax/reactjs_jsx_ppx_v2.ml
136135
jscomp/syntax/reactjs_jsx_ppx_v3.ml
137136
jscomp/outcome_printer/tweaked_reason_oprint.ml

jscomp/bsb/bsb.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ This file is integrity is not impacted by `.bscache`. whenever `.bscache` change
8484
# Appendix
8585
[source,ocaml]
8686
--------------
87-
module String_set = Set.Make(String)
87+
module Set_string = Set.Make(String)
8888

89-
(* let v = String_set.of_list ["List" ; "Set" ; "String" ; "Test_order"] *)
90-
let v = String_set.of_list []
89+
(* let v = Set_string.of_list ["List" ; "Set" ; "String" ; "Test_order"] *)
90+
let v = Set_string.of_list []
9191
let deseralize f =
9292
let ichan = open_in_bin f in
93-
let v : String_set.t = input_value ichan in
93+
let v : Set_string.t = input_value ichan in
9494
close_in ichan ;
9595
v
9696

@@ -101,7 +101,7 @@ let time f arg =
101101
print_endline (Printf.sprintf "%f elapsed" (v1 -. v0))
102102

103103
let deseralize_and_compare f =
104-
ignore @@ String_set.equal v (deseralize f)
104+
ignore @@ Set_string.equal v (deseralize f)
105105

106106
let seralize f =
107107
let ochan = open_out_bin f in

jscomp/bsb/bsb_build_util.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ let pp_packages_rev ppf lst =
173173
Ext_list.rev_iter lst (fun s -> Format.fprintf ppf "%s " s)
174174

175175
let rec walk_all_deps_aux
176-
(visited : string String_hashtbl.t)
176+
(visited : string Hash_string.t)
177177
(paths : string list)
178178
(top : bool)
179179
(dir : string)
@@ -182,7 +182,7 @@ let rec walk_all_deps_aux
182182
match Ext_json_parse.parse_json_from_file bsconfig_json with
183183
| Obj {map; loc} ->
184184
let cur_package_name =
185-
match String_map.find_opt map Bsb_build_schemas.name with
185+
match Map_string.find_opt map Bsb_build_schemas.name with
186186
| Some (Str {str }) -> str
187187
| Some _
188188
| None -> Bsb_exception.errorf ~loc "package name missing in %s/bsconfig.json" dir
@@ -195,7 +195,7 @@ let rec walk_all_deps_aux
195195
Bsb_log.error "@{<error>Cyclic dependencies in package stack@}@.";
196196
exit 2
197197
end;
198-
if String_hashtbl.mem visited cur_package_name then
198+
if Hash_string.mem visited cur_package_name then
199199
Bsb_log.info
200200
"@{<info>Visited before@} %s@." cur_package_name
201201
else
@@ -221,13 +221,13 @@ let rec walk_all_deps_aux
221221
explore_deps Bsb_build_schemas.bs_dependencies;
222222
if top then explore_deps Bsb_build_schemas.bs_dev_dependencies;
223223
cb {top ; proj_dir = dir};
224-
String_hashtbl.add visited cur_package_name dir;
224+
Hash_string.add visited cur_package_name dir;
225225
end
226226
| _ -> ()
227227
| exception _ ->
228228
Bsb_exception.invalid_json bsconfig_json
229229

230230

231231
let walk_all_deps dir cb =
232-
let visited = String_hashtbl.create 0 in
232+
let visited = Hash_string.create 0 in
233233
walk_all_deps_aux visited [] true dir cb

jscomp/bsb/bsb_config_parse.ml

+30-30
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let resolve_package cwd package_name =
3333
package_install_path = x // Bsb_config.lib_ocaml
3434
}
3535

36-
type json_map = Ext_json_types.t String_map.t
36+
type json_map = Ext_json_types.t Map_string.t
3737
(* Key is the path *)
3838
let (|?) m (key, cb) =
3939
m |> Ext_json.test key cb
@@ -71,7 +71,7 @@ let extract_main_entries (map :json_map) =
7171
| _ -> failwith "Unrecognized object inside array 'entries' field.")
7272
field in
7373
let entries = ref Bsb_default.main_entries in
74-
begin match String_map.find_opt map Bsb_build_schemas.entries with
74+
begin match Map_string.find_opt map Bsb_build_schemas.entries with
7575
| Some (Arr {content = s}) -> entries := extract_entries s
7676
| _ -> ()
7777
end; !entries
@@ -85,7 +85,7 @@ let package_specs_from_bsconfig () =
8585
begin match json with
8686
| Obj {map} ->
8787
begin
88-
match String_map.find_opt map Bsb_build_schemas.package_specs with
88+
match Map_string.find_opt map Bsb_build_schemas.package_specs with
8989
| Some x ->
9090
Bsb_package_specs.from_json x
9191
| None ->
@@ -104,7 +104,7 @@ let package_specs_from_bsconfig () =
104104
let extract_package_name_and_namespace
105105
(map : json_map) : string * string option =
106106
let package_name =
107-
match String_map.find_opt map Bsb_build_schemas.name with
107+
match Map_string.find_opt map Bsb_build_schemas.name with
108108

109109
| Some (Str { str = "_" } as config)
110110
->
@@ -119,7 +119,7 @@ let extract_package_name_and_namespace
119119
"field name is required"
120120
in
121121
let namespace =
122-
match String_map.find_opt map Bsb_build_schemas.namespace with
122+
match Map_string.find_opt map Bsb_build_schemas.namespace with
123123
| None
124124
| Some (False _)
125125
-> None
@@ -142,7 +142,7 @@ let extract_package_name_and_namespace
142142
(kinda check npm upgrade)
143143
*)
144144
let check_version_exit (map : json_map) stdlib_path =
145-
match String_map.find_exn map Bsb_build_schemas.version with
145+
match Map_string.find_exn map Bsb_build_schemas.version with
146146
| Str {str } ->
147147
if str <> Bs_version.version then
148148
begin
@@ -158,7 +158,7 @@ let check_version_exit (map : json_map) stdlib_path =
158158
| _ -> assert false
159159

160160
let check_stdlib (map : json_map) cwd (*built_in_package*) =
161-
match String_map.find_opt map Bsb_build_schemas.use_stdlib with
161+
match Map_string.find_opt map Bsb_build_schemas.use_stdlib with
162162
| Some (False _) -> None
163163
| None
164164
| Some _ ->
@@ -180,7 +180,7 @@ let check_stdlib (map : json_map) cwd (*built_in_package*) =
180180

181181
end
182182
let extract_bs_suffix_exn (map : json_map) =
183-
match String_map.find_opt map Bsb_build_schemas.suffix with
183+
match Map_string.find_opt map Bsb_build_schemas.suffix with
184184
| None -> false
185185
| Some (Str {str} as config ) ->
186186
if str = Literals.suffix_js then false
@@ -193,11 +193,11 @@ let extract_bs_suffix_exn (map : json_map) =
193193

194194
let extract_gentype_config (map : json_map) cwd
195195
: Bsb_config_types.gentype_config option =
196-
match String_map.find_opt map Bsb_build_schemas.gentypeconfig with
196+
match Map_string.find_opt map Bsb_build_schemas.gentypeconfig with
197197
| None -> None
198198
| Some (Obj {map = obj}) ->
199199
Some { path =
200-
match String_map.find_opt obj Bsb_build_schemas.path with
200+
match Map_string.find_opt obj Bsb_build_schemas.path with
201201
| None ->
202202
(Bsb_build_util.resolve_bsb_magic_file
203203
~cwd ~desc:"gentype.exe"
@@ -215,7 +215,7 @@ let extract_gentype_config (map : json_map) cwd
215215
config "gentypeconfig expect an object"
216216

217217
let extract_refmt (map : json_map) cwd : Bsb_config_types.refmt =
218-
match String_map.find_opt map Bsb_build_schemas.refmt with
218+
match Map_string.find_opt map Bsb_build_schemas.refmt with
219219
| Some (Flo {flo} as config) ->
220220
begin match flo with
221221
| "3" -> Bsb_config_types.Refmt_v3
@@ -232,14 +232,14 @@ let extract_refmt (map : json_map) cwd : Bsb_config_types.refmt =
232232
Refmt_none
233233

234234
let extract_string (map : json_map) (field : string) cb =
235-
match String_map.find_opt map field with
235+
match Map_string.find_opt map field with
236236
| None -> None
237237
| Some (Str{str}) -> cb str
238238
| Some config ->
239239
Bsb_exception.config_error config (field ^ " expect a string" )
240240

241241
let extract_boolean (map : json_map) (field : string) (default : bool) : bool =
242-
match String_map.find_opt map field with
242+
match Map_string.find_opt map field with
243243
| None -> default
244244
| Some (True _ ) -> true
245245
| Some (False _) -> false
@@ -250,7 +250,7 @@ let extract_reason_react_jsx (map : json_map) =
250250
let default : Bsb_config_types.reason_react_jsx option ref = ref None in
251251
map
252252
|? (Bsb_build_schemas.reason, `Obj begin fun m ->
253-
match String_map.find_opt m Bsb_build_schemas.react_jsx with
253+
match Map_string.find_opt m Bsb_build_schemas.react_jsx with
254254
| Some (Flo{loc; flo}) ->
255255
begin match flo with
256256
| "2" ->
@@ -267,32 +267,32 @@ let extract_reason_react_jsx (map : json_map) =
267267
!default
268268

269269
let extract_warning (map : json_map) =
270-
match String_map.find_opt map Bsb_build_schemas.warnings with
270+
match Map_string.find_opt map Bsb_build_schemas.warnings with
271271
| None -> None
272272
| Some (Obj {map }) -> Bsb_warning.from_map map
273273
| Some config -> Bsb_exception.config_error config "expect an object"
274274

275275
let extract_ignored_dirs (map : json_map) =
276-
match String_map.find_opt map Bsb_build_schemas.ignored_dirs with
277-
| None -> String_set.empty
276+
match Map_string.find_opt map Bsb_build_schemas.ignored_dirs with
277+
| None -> Set_string.empty
278278
| Some (Arr {content}) ->
279-
String_set.of_list (Bsb_build_util.get_list_string content)
279+
Set_string.of_list (Bsb_build_util.get_list_string content)
280280
| Some config ->
281281
Bsb_exception.config_error config "expect an array of string"
282282

283283
let extract_generators (map : json_map) =
284-
let generators = ref String_map.empty in
285-
(match String_map.find_opt map Bsb_build_schemas.generators with
284+
let generators = ref Map_string.empty in
285+
(match Map_string.find_opt map Bsb_build_schemas.generators with
286286
| None -> ()
287287
| Some (Arr {content = s}) ->
288288
generators :=
289-
Ext_array.fold_left s String_map.empty (fun acc json ->
289+
Ext_array.fold_left s Map_string.empty (fun acc json ->
290290
match json with
291291
| Obj {map = m ; loc} ->
292-
begin match String_map.find_opt m Bsb_build_schemas.name,
293-
String_map.find_opt m Bsb_build_schemas.command with
292+
begin match Map_string.find_opt m Bsb_build_schemas.name,
293+
Map_string.find_opt m Bsb_build_schemas.command with
294294
| Some (Str {str = name}), Some ( Str {str = command}) ->
295-
String_map.add acc name command
295+
Map_string.add acc name command
296296
| _, _ ->
297297
Bsb_exception.errorf ~loc {| generators exepect format like { "name" : "cppo", "command" : "cppo $in -o $out"} |}
298298
end
@@ -305,7 +305,7 @@ let extract_generators (map : json_map) =
305305

306306
let extract_dependencies (map : json_map) cwd (field : string )
307307
: Bsb_config_types.dependencies =
308-
match String_map.find_opt map field with
308+
match Map_string.find_opt map field with
309309
| None -> []
310310
| Some (Arr ({content = s})) ->
311311
Ext_list.map (Bsb_build_util.get_list_string s) (fun s -> resolve_package cwd (Bsb_pkg_types.string_as_package s))
@@ -315,7 +315,7 @@ let extract_dependencies (map : json_map) cwd (field : string )
315315

316316
(* return an empty array if not found *)
317317
let extract_string_list (map : json_map) (field : string) : string list =
318-
match String_map.find_opt map field with
318+
match Map_string.find_opt map field with
319319
| None -> []
320320
| Some (Arr {content = s}) ->
321321
Bsb_build_util.get_list_string s
@@ -326,7 +326,7 @@ let extract_ppx
326326
(map : json_map)
327327
(field : string)
328328
~(cwd : string) : Bsb_config_types.ppx list =
329-
match String_map.find_opt map field with
329+
match Map_string.find_opt map field with
330330
| None -> []
331331
| Some (Arr {content }) ->
332332
let resolve s =
@@ -406,7 +406,7 @@ let interpret_json
406406
(* The default situation is empty *)
407407
let built_in_package = check_stdlib map per_proj_dir in
408408
let package_specs =
409-
match String_map.find_opt map Bsb_build_schemas.package_specs with
409+
match Map_string.find_opt map Bsb_build_schemas.package_specs with
410410
| Some x ->
411411
Bsb_package_specs.from_json x
412412
| None -> Bsb_package_specs.default_package_specs
@@ -425,7 +425,7 @@ let interpret_json
425425
if toplevel then
426426
extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dev_dependencies
427427
else [] in
428-
begin match String_map.find_opt map Bsb_build_schemas.sources with
428+
begin match Map_string.find_opt map Bsb_build_schemas.sources with
429429
| Some sources ->
430430
let cut_generators =
431431
extract_boolean map Bsb_build_schemas.cut_generators false in
@@ -465,7 +465,7 @@ let interpret_json
465465
| None -> package_specs
466466
| Some x -> x );
467467
file_groups = groups;
468-
files_to_install = String_hash_set.create 96;
468+
files_to_install = Hash_set_string.create 96;
469469
built_in_dependency = built_in_package;
470470
generate_merlin =
471471
extract_boolean map Bsb_build_schemas.generate_merlin true;

jscomp/bsb/bsb_config_types.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ type t =
7575
js_post_build_cmd : string option;
7676
package_specs : Bsb_package_specs.t ;
7777
file_groups : Bsb_file_groups.t;
78-
files_to_install : String_hash_set.t ;
78+
files_to_install : Hash_set_string.t ;
7979
generate_merlin : bool ;
8080
reason_react_jsx : reason_react_jsx option; (* whether apply PPX transform or not*)
8181
entries : entries_t list ;
82-
generators : command String_map.t ;
82+
generators : command Map_string.t ;
8383
cut_generators : bool; (* note when used as a dev mode, we will always ignore it *)
8484
bs_suffix : bool ; (* true means [.bs.js] we should pass [-bs-suffix] flag *)
8585
gentype_config : gentype_config option;

jscomp/bsb/bsb_db_encode.ml

+9-9
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,24 @@ let make_encoding length buf =
6464
*)
6565
let encode_single (db : Bsb_db.t) (buf : Ext_buffer.t) =
6666
nl buf ; (* module name section *)
67-
let len = String_map.cardinal db in
67+
let len = Map_string.cardinal db in
6868
Ext_buffer.add_string_char buf (string_of_int len) '\n';
69-
let mapping = String_hashtbl.create 50 in
70-
String_map.iter db (fun name {dir} ->
69+
let mapping = Hash_string.create 50 in
70+
Map_string.iter db (fun name {dir} ->
7171
Ext_buffer.add_string_char buf name '\n';
72-
if not (String_hashtbl.mem mapping dir) then
73-
String_hashtbl.add mapping dir (String_hashtbl.length mapping)
72+
if not (Hash_string.mem mapping dir) then
73+
Hash_string.add mapping dir (Hash_string.length mapping)
7474
);
75-
let length = String_hashtbl.length mapping in
75+
let length = Hash_string.length mapping in
7676
let rev_mapping = Array.make length "" in
77-
String_hashtbl.iter mapping (fun k i -> Array.unsafe_set rev_mapping i k);
77+
Hash_string.iter mapping (fun k i -> Array.unsafe_set rev_mapping i k);
7878
(* directory name section *)
7979
Ext_array.iter rev_mapping (fun s -> Ext_buffer.add_string_char buf s '\t');
8080
nl buf; (* module name info section *)
8181
let len_encoding = make_encoding length buf in
82-
String_map.iter db (fun _ module_info ->
82+
Map_string.iter db (fun _ module_info ->
8383
len_encoding buf
84-
(String_hashtbl.find_exn mapping module_info.dir lsl 1 + Obj.magic module_info.case ))
84+
(Hash_string.find_exn mapping module_info.dir lsl 1 + Obj.magic module_info.case ))
8585

8686
let encode (dbs : Bsb_db.ts) buf =
8787

0 commit comments

Comments
 (0)