Skip to content

Commit a145264

Browse files
committed
extract unsafe_sub
1 parent ce1dd58 commit a145264

15 files changed

+133
-16
lines changed

jscomp/bsb/bsb_clean.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let clean_bs_garbage bsc_dir proj_dir =
4747
try
4848
Bsb_parse_sources.clean_re_js proj_dir; (* clean re.js files*)
4949
ninja_clean bsc_dir proj_dir ;
50-
List.iter try_remove Bsb_config.all_lib_artifacts;
50+
Ext_list.iter Bsb_config.all_lib_artifacts try_remove ;
5151
with
5252
e ->
5353
Bsb_log.warn "@{<warning>Failed@} to clean due to %s" (Printexc.to_string e)

jscomp/bsb/bsb_config_parse.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ let extract_ignored_dirs (map : json_map) =
276276
let interpret_json
277277
~override_package_specs
278278
~bsc_dir
279-
~generate_watch_metadata
279+
~(generate_watch_metadata : bool)
280280
~not_dev
281281
cwd
282282

jscomp/bsb_helper/bsb_db_decode.ml

+2-4
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,9 @@ and decode_modules (x : string) (offset : cursor) module_number : string array =
7575
if String.unsafe_get x !cur = '\n' then
7676
begin
7777
let offs = !last in
78-
let len = (!cur - !last) in
79-
let b = Bytes.create len in
80-
Ext_bytes.unsafe_blit_string x offs b 0 len;
78+
let len = (!cur - !last) in
8179
Array.unsafe_set result !tasks
82-
(Bytes.unsafe_to_string b);
80+
(Ext_string.unsafe_sub x offs len);
8381
incr tasks;
8482
last := !cur + 1;
8583
end;

jscomp/ext/ext_string.ml

+6-1
Original file line numberDiff line numberDiff line change
@@ -567,4 +567,9 @@ let get_1_2_3_4 (x : string) ~off len : int =
567567
else if len = 2 then get_int_2 x off
568568
else if len = 3 then get_int_3 x off
569569
else if len = 4 then get_int_4 x off
570-
else assert false
570+
else assert false
571+
572+
let unsafe_sub x offs len =
573+
let b = Bytes.create len in
574+
Ext_bytes.unsafe_blit_string x offs b 0 len;
575+
(Bytes.unsafe_to_string b);

jscomp/ext/ext_string.mli

+7-1
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,10 @@ val get_1_2_3_4 :
216216
string ->
217217
off:int ->
218218
int ->
219-
int
219+
int
220+
221+
val unsafe_sub :
222+
string ->
223+
int ->
224+
int ->
225+
string

lib/4.02.3/bsb.ml

+13-2
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,12 @@ val get_1_2_3_4 :
810810
off:int ->
811811
int ->
812812
int
813+
814+
val unsafe_sub :
815+
string ->
816+
int ->
817+
int ->
818+
string
813819
end = struct
814820
#1 "ext_string.ml"
815821
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1374,6 +1380,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
13741380
else if len = 3 then get_int_3 x off
13751381
else if len = 4 then get_int_4 x off
13761382
else assert false
1383+
1384+
let unsafe_sub x offs len =
1385+
let b = Bytes.create len in
1386+
Ext_bytes.unsafe_blit_string x offs b 0 len;
1387+
(Bytes.unsafe_to_string b);
13771388
end
13781389
module Bsb_pkg_types : sig
13791390
#1 "bsb_pkg_types.mli"
@@ -9461,7 +9472,7 @@ let clean_bs_garbage bsc_dir proj_dir =
94619472
try
94629473
Bsb_parse_sources.clean_re_js proj_dir; (* clean re.js files*)
94639474
ninja_clean bsc_dir proj_dir ;
9464-
List.iter try_remove Bsb_config.all_lib_artifacts;
9475+
Ext_list.iter Bsb_config.all_lib_artifacts try_remove ;
94659476
with
94669477
e ->
94679478
Bsb_log.warn "@{<warning>Failed@} to clean due to %s" (Printexc.to_string e)
@@ -11118,7 +11129,7 @@ let extract_ignored_dirs (map : json_map) =
1111811129
let interpret_json
1111911130
~override_package_specs
1112011131
~bsc_dir
11121-
~generate_watch_metadata
11132+
~(generate_watch_metadata : bool)
1112211133
~not_dev
1112311134
cwd
1112411135

lib/4.02.3/bsb_helper.ml

+13-4
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,12 @@ val get_1_2_3_4 :
11491149
off:int ->
11501150
int ->
11511151
int
1152+
1153+
val unsafe_sub :
1154+
string ->
1155+
int ->
1156+
int ->
1157+
string
11521158
end = struct
11531159
#1 "ext_string.ml"
11541160
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1713,6 +1719,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
17131719
else if len = 3 then get_int_3 x off
17141720
else if len = 4 then get_int_4 x off
17151721
else assert false
1722+
1723+
let unsafe_sub x offs len =
1724+
let b = Bytes.create len in
1725+
Ext_bytes.unsafe_blit_string x offs b 0 len;
1726+
(Bytes.unsafe_to_string b);
17161727
end
17171728
module Ext_list : sig
17181729
#1 "ext_list.mli"
@@ -4020,11 +4031,9 @@ and decode_modules (x : string) (offset : cursor) module_number : string array =
40204031
if String.unsafe_get x !cur = '\n' then
40214032
begin
40224033
let offs = !last in
4023-
let len = (!cur - !last) in
4024-
let b = Bytes.create len in
4025-
Ext_bytes.unsafe_blit_string x offs b 0 len;
4034+
let len = (!cur - !last) in
40264035
Array.unsafe_set result !tasks
4027-
(Bytes.unsafe_to_string b);
4036+
(Ext_string.unsafe_sub x offs len);
40284037
incr tasks;
40294038
last := !cur + 1;
40304039
end;

lib/4.02.3/bsdep.ml

+11
Original file line numberDiff line numberDiff line change
@@ -23599,6 +23599,12 @@ val get_1_2_3_4 :
2359923599
off:int ->
2360023600
int ->
2360123601
int
23602+
23603+
val unsafe_sub :
23604+
string ->
23605+
int ->
23606+
int ->
23607+
string
2360223608
end = struct
2360323609
#1 "ext_string.ml"
2360423610
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -24163,6 +24169,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
2416324169
else if len = 3 then get_int_3 x off
2416424170
else if len = 4 then get_int_4 x off
2416524171
else assert false
24172+
24173+
let unsafe_sub x offs len =
24174+
let b = Bytes.create len in
24175+
Ext_bytes.unsafe_blit_string x offs b 0 len;
24176+
(Bytes.unsafe_to_string b);
2416624177
end
2416724178
module Ext_list : sig
2416824179
#1 "ext_list.mli"

lib/4.02.3/bsppx.ml

+11
Original file line numberDiff line numberDiff line change
@@ -5872,6 +5872,12 @@ val get_1_2_3_4 :
58725872
off:int ->
58735873
int ->
58745874
int
5875+
5876+
val unsafe_sub :
5877+
string ->
5878+
int ->
5879+
int ->
5880+
string
58755881
end = struct
58765882
#1 "ext_string.ml"
58775883
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -6436,6 +6442,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
64366442
else if len = 3 then get_int_3 x off
64376443
else if len = 4 then get_int_4 x off
64386444
else assert false
6445+
6446+
let unsafe_sub x offs len =
6447+
let b = Bytes.create len in
6448+
Ext_bytes.unsafe_blit_string x offs b 0 len;
6449+
(Bytes.unsafe_to_string b);
64396450
end
64406451
module Ext_list : sig
64416452
#1 "ext_list.mli"

lib/4.02.3/unstable/all_ounit_tests.ml

+11
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,12 @@ val get_1_2_3_4 :
22762276
off:int ->
22772277
int ->
22782278
int
2279+
2280+
val unsafe_sub :
2281+
string ->
2282+
int ->
2283+
int ->
2284+
string
22792285
end = struct
22802286
#1 "ext_string.ml"
22812287
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -2840,6 +2846,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
28402846
else if len = 3 then get_int_3 x off
28412847
else if len = 4 then get_int_4 x off
28422848
else assert false
2849+
2850+
let unsafe_sub x offs len =
2851+
let b = Bytes.create len in
2852+
Ext_bytes.unsafe_blit_string x offs b 0 len;
2853+
(Bytes.unsafe_to_string b);
28432854
end
28442855
module Ounit_array_tests
28452856
= struct

lib/4.02.3/unstable/bsb_native.ml

+13-2
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,12 @@ val get_1_2_3_4 :
810810
off:int ->
811811
int ->
812812
int
813+
814+
val unsafe_sub :
815+
string ->
816+
int ->
817+
int ->
818+
string
813819
end = struct
814820
#1 "ext_string.ml"
815821
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1374,6 +1380,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
13741380
else if len = 3 then get_int_3 x off
13751381
else if len = 4 then get_int_4 x off
13761382
else assert false
1383+
1384+
let unsafe_sub x offs len =
1385+
let b = Bytes.create len in
1386+
Ext_bytes.unsafe_blit_string x offs b 0 len;
1387+
(Bytes.unsafe_to_string b);
13771388
end
13781389
module Bsb_pkg_types : sig
13791390
#1 "bsb_pkg_types.mli"
@@ -9461,7 +9472,7 @@ let clean_bs_garbage bsc_dir proj_dir =
94619472
try
94629473
Bsb_parse_sources.clean_re_js proj_dir; (* clean re.js files*)
94639474
ninja_clean bsc_dir proj_dir ;
9464-
List.iter try_remove Bsb_config.all_lib_artifacts;
9475+
Ext_list.iter Bsb_config.all_lib_artifacts try_remove ;
94659476
with
94669477
e ->
94679478
Bsb_log.warn "@{<warning>Failed@} to clean due to %s" (Printexc.to_string e)
@@ -11150,7 +11161,7 @@ let extract_ignored_dirs (map : json_map) =
1115011161
let interpret_json
1115111162
~override_package_specs
1115211163
~bsc_dir
11153-
~generate_watch_metadata
11164+
~(generate_watch_metadata : bool)
1115411165
~not_dev
1115511166
cwd
1115611167

lib/4.02.3/unstable/bspack.ml

+11
Original file line numberDiff line numberDiff line change
@@ -5069,6 +5069,12 @@ val get_1_2_3_4 :
50695069
off:int ->
50705070
int ->
50715071
int
5072+
5073+
val unsafe_sub :
5074+
string ->
5075+
int ->
5076+
int ->
5077+
string
50725078
end = struct
50735079
#1 "ext_string.ml"
50745080
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -5633,6 +5639,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
56335639
else if len = 3 then get_int_3 x off
56345640
else if len = 4 then get_int_4 x off
56355641
else assert false
5642+
5643+
let unsafe_sub x offs len =
5644+
let b = Bytes.create len in
5645+
Ext_bytes.unsafe_blit_string x offs b 0 len;
5646+
(Bytes.unsafe_to_string b);
56365647
end
56375648
module Ext_filename : sig
56385649
#1 "ext_filename.mli"

lib/4.02.3/unstable/js_compiler.ml

+11
Original file line numberDiff line numberDiff line change
@@ -5559,6 +5559,12 @@ val get_1_2_3_4 :
55595559
off:int ->
55605560
int ->
55615561
int
5562+
5563+
val unsafe_sub :
5564+
string ->
5565+
int ->
5566+
int ->
5567+
string
55625568
end = struct
55635569
#1 "ext_string.ml"
55645570
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -6123,6 +6129,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
61236129
else if len = 3 then get_int_3 x off
61246130
else if len = 4 then get_int_4 x off
61256131
else assert false
6132+
6133+
let unsafe_sub x offs len =
6134+
let b = Bytes.create len in
6135+
Ext_bytes.unsafe_blit_string x offs b 0 len;
6136+
(Bytes.unsafe_to_string b);
61266137
end
61276138
module Ext_list : sig
61286139
#1 "ext_list.mli"

lib/4.02.3/unstable/native_ppx.ml

+11
Original file line numberDiff line numberDiff line change
@@ -5537,6 +5537,12 @@ val get_1_2_3_4 :
55375537
off:int ->
55385538
int ->
55395539
int
5540+
5541+
val unsafe_sub :
5542+
string ->
5543+
int ->
5544+
int ->
5545+
string
55405546
end = struct
55415547
#1 "ext_string.ml"
55425548
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -6101,6 +6107,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
61016107
else if len = 3 then get_int_3 x off
61026108
else if len = 4 then get_int_4 x off
61036109
else assert false
6110+
6111+
let unsafe_sub x offs len =
6112+
let b = Bytes.create len in
6113+
Ext_bytes.unsafe_blit_string x offs b 0 len;
6114+
(Bytes.unsafe_to_string b);
61046115
end
61056116
module Ext_list : sig
61066117
#1 "ext_list.mli"

lib/4.02.3/whole_compiler.ml

+11
Original file line numberDiff line numberDiff line change
@@ -22863,6 +22863,12 @@ val get_1_2_3_4 :
2286322863
off:int ->
2286422864
int ->
2286522865
int
22866+
22867+
val unsafe_sub :
22868+
string ->
22869+
int ->
22870+
int ->
22871+
string
2286622872
end = struct
2286722873
#1 "ext_string.ml"
2286822874
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -23427,6 +23433,11 @@ let get_1_2_3_4 (x : string) ~off len : int =
2342723433
else if len = 3 then get_int_3 x off
2342823434
else if len = 4 then get_int_4 x off
2342923435
else assert false
23436+
23437+
let unsafe_sub x offs len =
23438+
let b = Bytes.create len in
23439+
Ext_bytes.unsafe_blit_string x offs b 0 len;
23440+
(Bytes.unsafe_to_string b);
2343023441
end
2343123442
module Js_config : sig
2343223443
#1 "js_config.mli"

0 commit comments

Comments
 (0)