Skip to content

Commit f93b32e

Browse files
committed
Do not inline length of j strings.
1 parent 8e23169 commit f93b32e

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

jscomp/core/js_exp_make.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ let array_length ?comment (e : t) : t =
475475

476476
let string_length ?comment (e : t) : t =
477477
match e.expression_desc with
478-
| Str {txt} -> int ?comment (Int32.of_int (String.length txt))
478+
| Str {txt; delim=None} -> int ?comment (Int32.of_int (String.length txt))
479479
(* No optimization for {j||j}*)
480480
| _ -> { expression_desc = Length (e, String); comment }
481481

jscomp/test/chn_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ eq("File \"chn_test.ml\", line 63, characters 5-12", convert("\uD83D\uDE80\uD83D
183183
}
184184
});
185185

186-
eq("No inline string length", 14, 3);
186+
eq("No inline string length", "\uD83D\uDE80\0".length, 3);
187187

188188
eq("File \"chn_test.ml\", line 72, characters 6-13", Caml_string.get("\uD83D\uDE80\0", 0), 128640);
189189

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67731,7 +67731,7 @@ let array_length ?comment (e : t) : t =
6773167731

6773267732
let string_length ?comment (e : t) : t =
6773367733
match e.expression_desc with
67734-
| Str {txt} -> int ?comment (Int32.of_int (String.length txt))
67734+
| Str {txt; delim=None} -> int ?comment (Int32.of_int (String.length txt))
6773567735
(* No optimization for {j||j}*)
6773667736
| _ -> { expression_desc = Length (e, String); comment }
6773767737

lib/4.06.1/unstable/js_playground_compiler.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67731,7 +67731,7 @@ let array_length ?comment (e : t) : t =
6773167731

6773267732
let string_length ?comment (e : t) : t =
6773367733
match e.expression_desc with
67734-
| Str {txt} -> int ?comment (Int32.of_int (String.length txt))
67734+
| Str {txt; delim=None} -> int ?comment (Int32.of_int (String.length txt))
6773567735
(* No optimization for {j||j}*)
6773667736
| _ -> { expression_desc = Length (e, String); comment }
6773767737

lib/4.06.1/whole_compiler.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235893,7 +235893,7 @@ let array_length ?comment (e : t) : t =
235893235893

235894235894
let string_length ?comment (e : t) : t =
235895235895
match e.expression_desc with
235896-
| Str {txt} -> int ?comment (Int32.of_int (String.length txt))
235896+
| Str {txt; delim=None} -> int ?comment (Int32.of_int (String.length txt))
235897235897
(* No optimization for {j||j}*)
235898235898
| _ -> { expression_desc = Length (e, String); comment }
235899235899

0 commit comments

Comments
 (0)