Skip to content

Commit d1cdc16

Browse files
committed
specialize string_of_int
1 parent ffe0981 commit d1cdc16

File tree

133 files changed

+731
-728
lines changed

Some content is hidden

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

133 files changed

+731
-728
lines changed

jscomp/all.depend

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,8 @@ core/lam_compile_main.cmx : ext/literals.cmx core/lam_util.cmx \
675675
core/js_exp_make.cmx core/js_dump_program.cmx common/js_config.cmx \
676676
core/js_cmj_format.cmx core/j.cmx ext/ident_set.cmx ext/ext_string.cmx \
677677
ext/ext_pervasives.cmx ext/ext_path.cmx ext/ext_namespace.cmx \
678-
common/ext_log.cmx ext/ext_list.cmx ext/ext_ident.cmx \
679-
ext/ext_filename.cmx ext/ext_char.cmx core/lam_compile_main.cmi
678+
common/ext_log.cmx ext/ext_list.cmx ext/ext_filename.cmx ext/ext_char.cmx \
679+
core/lam_compile_main.cmi
680680
core/js_implementation.cmx : core/ocaml_parse.cmx ext/literals.cmx \
681681
core/lam_compile_main.cmx core/lam_compile_env.cmx common/js_config.cmx \
682682
ext/ext_string.cmx ext/ext_pervasives.cmx ext/ext_namespace.cmx \

jscomp/core/lam_compile_main.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ let compile_group ({filename = file_name; env;} as meta : Lam_stats.t)
7171
Note the arity of [print_endline] is already analyzed before,
7272
so it should be safe
7373
*)
74-
| Single(_, ({name="string_of_int";_} as id),_ ), "pervasives.ml" ->
74+
(* | Single(_, ({name="string_of_int";_} as id),_ ), "pervasives.ml" ->
7575
Js_output.of_stmt @@ S.alias_variable id
7676
~exp:(
7777
let arg = Ext_ident.create "param" in
7878
E.ocaml_fun [arg] [S.return_stmt (E.int_to_string (E.var arg))]
79-
)
79+
) *)
8080

8181
(** Special handling for values in [Sys] *)
8282
| Single(_, ({name="max_array_length" | "max_string_length";_} as id) ,_ ), "sys.ml" ->

jscomp/stdlib/pervasives.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,12 @@ let bool_of_string = function
244244
| "false" -> false
245245
| _ -> invalid_arg "bool_of_string"
246246

247+
#if BS then
248+
external string_of_int : int -> string = "String" [@@bs.val]
249+
#else
247250
let string_of_int n =
248251
format_int "%d" n
249-
252+
#end
250253
external int_of_string : string -> int = "caml_int_of_string"
251254
external string_get : string -> int -> char = "%string_safe_get"
252255

jscomp/stdlib/pervasives.mli

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,12 @@ val bool_of_string : string -> bool
568568
Raise [Invalid_argument "bool_of_string"] if the string is not
569569
["true"] or ["false"]. *)
570570

571+
#if BS then
572+
external string_of_int : int -> string = "String" [@@bs.val]
573+
#else
571574
val string_of_int : int -> string
572575
(** Return the string representation of an integer, in decimal. *)
573-
576+
#end
574577
external int_of_string : string -> int = "caml_int_of_string"
575578
(** Convert the given string to an integer.
576579
The string is read in decimal (by default) or in hexadecimal (if it

jscomp/test/a_filename_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function eq(loc, x, y) {
1313
test_id[0] = test_id[0] + 1 | 0;
1414
suites[0] = /* :: */[
1515
/* tuple */[
16-
loc + (" id " + test_id[0]),
16+
loc + (" id " + String(test_id[0])),
1717
(function () {
1818
return /* Eq */Block.__(0, [
1919
x,

jscomp/test/a_scope_bug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function odd(_z) {
77
var z = _z;
88
var even = Caml_int32.imul(z, z);
99
var a = (even + 4 | 0) + even | 0;
10-
console.log("" + a);
10+
console.log(String(a));
1111
_z = 32;
1212
continue ;
1313

jscomp/test/arity_deopt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function eq(loc, x, y) {
1212
test_id[0] = test_id[0] + 1 | 0;
1313
suites[0] = /* :: */[
1414
/* tuple */[
15-
loc + (" id " + test_id[0]),
15+
loc + (" id " + String(test_id[0])),
1616
(function () {
1717
return /* Eq */Block.__(0, [
1818
x,

jscomp/test/array_subtle_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function eq(loc, param) {
1515
test_id[0] = test_id[0] + 1 | 0;
1616
suites[0] = /* :: */[
1717
/* tuple */[
18-
loc + (" id " + test_id[0]),
18+
loc + (" id " + String(test_id[0])),
1919
(function () {
2020
return /* Eq */Block.__(0, [
2121
x,

jscomp/test/ast_abstract_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function eq(loc, x, y) {
1212
test_id[0] = test_id[0] + 1 | 0;
1313
suites[0] = /* :: */[
1414
/* tuple */[
15-
loc + (" id " + test_id[0]),
15+
loc + (" id " + String(test_id[0])),
1616
(function () {
1717
return /* Eq */Block.__(0, [
1818
x,

jscomp/test/ast_js_mapper_poly_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function eq(loc, x, y) {
1313
test_id[0] = test_id[0] + 1 | 0;
1414
suites[0] = /* :: */[
1515
/* tuple */[
16-
loc + (" id " + test_id[0]),
16+
loc + (" id " + String(test_id[0])),
1717
(function () {
1818
return /* Eq */Block.__(0, [
1919
x,

0 commit comments

Comments
 (0)