Skip to content

Commit 98b1935

Browse files
committed
optimize empty file
1 parent f999db2 commit 98b1935

File tree

4 files changed

+52
-24
lines changed

4 files changed

+52
-24
lines changed

jscomp/bin/bsb.ml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4491,9 +4491,18 @@ let get_list_string s =
44914491
| _ -> None
44924492
) s
44934493

4494-
4494+
let bsc_group_1_includes = "bsc_group_1_includes"
4495+
let bsc_group_2_includes = "bsc_group_2_includes"
4496+
let bsc_group_3_includes = "bsc_group_3_includes"
4497+
let bsc_group_4_includes = "bsc_group_4_includes"
44954498
let string_of_bsb_dev_include i =
4496-
"bsc_group_" ^ string_of_int i ^ "includes"
4499+
match i with
4500+
| 1 -> bsc_group_1_includes
4501+
| 2 -> bsc_group_2_includes
4502+
| 3 -> bsc_group_3_includes
4503+
| 4 -> bsc_group_4_includes
4504+
| _ ->
4505+
"bsc_group_" ^ string_of_int i ^ "_includes"
44974506
end
44984507
module Bsb_dir : sig
44994508
#1 "bsb_dir.mli"

jscomp/bin/bsb_helper.ml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,12 +2356,15 @@ let handle_bin_depfile oprefix (fn : string) index : unit =
23562356
v
23572357
end
23582358
) ([],String.length dependent_file) set in
2359-
let deps = Ext_string.unsafe_concat_with_length len
2360-
space
2361-
(dependent_file :: files)
2362-
in
2363-
let output = input_file ^ Literals.suffix_mlastd in
2364-
Ext_pervasives.with_file_as_chan output (fun v -> output_string v deps)
2359+
2360+
let output = input_file ^ Literals.suffix_mlastd in
2361+
if files = [] then
2362+
close_out (open_out_bin output)
2363+
else
2364+
let deps = Ext_string.unsafe_concat_with_length len
2365+
space
2366+
(dependent_file :: files) in
2367+
Ext_pervasives.with_file_as_chan output (fun v -> output_string v deps)
23652368

23662369
| None ->
23672370
begin match Ext_string.ends_with_then_chop fn Literals.suffix_mliast with
@@ -2391,11 +2394,13 @@ let handle_bin_depfile oprefix (fn : string) index : unit =
23912394
end
23922395

23932396
) ([], String.length dependent_file) set in
2394-
let deps = Ext_string.unsafe_concat_with_length len
2395-
space
2396-
(dependent_file :: files) in
23972397
let output = input_file ^ Literals.suffix_mliastd in
2398-
Ext_pervasives.with_file_as_chan output (fun v -> output_string v deps)
2398+
if files = [] then close_out (open_out_bin output)
2399+
else
2400+
let deps = Ext_string.unsafe_concat_with_length len
2401+
space
2402+
(dependent_file :: files) in
2403+
Ext_pervasives.with_file_as_chan output (fun v -> output_string v deps)
23992404
| None ->
24002405
raise (Arg.Bad ("don't know what to do with " ^ fn))
24012406
end

jscomp/bsb/bsb_build_util.ml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ let get_list_string s =
9292
| _ -> None
9393
) s
9494

95-
95+
let bsc_group_1_includes = "bsc_group_1_includes"
96+
let bsc_group_2_includes = "bsc_group_2_includes"
97+
let bsc_group_3_includes = "bsc_group_3_includes"
98+
let bsc_group_4_includes = "bsc_group_4_includes"
9699
let string_of_bsb_dev_include i =
97-
"bsc_group_" ^ string_of_int i ^ "includes"
100+
match i with
101+
| 1 -> bsc_group_1_includes
102+
| 2 -> bsc_group_2_includes
103+
| 3 -> bsc_group_3_includes
104+
| 4 -> bsc_group_4_includes
105+
| _ ->
106+
"bsc_group_" ^ string_of_int i ^ "_includes"

jscomp/depends/depends_post_process.ml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,15 @@ let handle_bin_depfile oprefix (fn : string) index : unit =
8787
v
8888
end
8989
) ([],String.length dependent_file) set in
90-
let deps = Ext_string.unsafe_concat_with_length len
91-
space
92-
(dependent_file :: files)
93-
in
94-
let output = input_file ^ Literals.suffix_mlastd in
95-
Ext_pervasives.with_file_as_chan output (fun v -> output_string v deps)
90+
91+
let output = input_file ^ Literals.suffix_mlastd in
92+
if files = [] then
93+
close_out (open_out_bin output)
94+
else
95+
let deps = Ext_string.unsafe_concat_with_length len
96+
space
97+
(dependent_file :: files) in
98+
Ext_pervasives.with_file_as_chan output (fun v -> output_string v deps)
9699

97100
| None ->
98101
begin match Ext_string.ends_with_then_chop fn Literals.suffix_mliast with
@@ -122,11 +125,13 @@ let handle_bin_depfile oprefix (fn : string) index : unit =
122125
end
123126

124127
) ([], String.length dependent_file) set in
125-
let deps = Ext_string.unsafe_concat_with_length len
126-
space
127-
(dependent_file :: files) in
128128
let output = input_file ^ Literals.suffix_mliastd in
129-
Ext_pervasives.with_file_as_chan output (fun v -> output_string v deps)
129+
if files = [] then close_out (open_out_bin output)
130+
else
131+
let deps = Ext_string.unsafe_concat_with_length len
132+
space
133+
(dependent_file :: files) in
134+
Ext_pervasives.with_file_as_chan output (fun v -> output_string v deps)
130135
| None ->
131136
raise (Arg.Bad ("don't know what to do with " ^ fn))
132137
end

0 commit comments

Comments
 (0)