-
Notifications
You must be signed in to change notification settings - Fork 471
Turn on optimizations for unicode strings. #5457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ type t = J.expression | |
*) | ||
let rec remove_pure_sub_exp (x : t) : t option = | ||
match x.expression_desc with | ||
| Var _ | Str _ | Number _ -> None (* Can be refined later *) | ||
| Var _ | Str _ | Unicode _ | Number _ -> None (* Can be refined later *) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like same behaviour as strings: both pure. |
||
| Array_index (a, b) -> | ||
if is_pure_sub_exp a && is_pure_sub_exp b then None else Some x | ||
| Array (xs, _mutable_flag) -> | ||
|
@@ -173,7 +173,7 @@ module L = Literals | |
let typeof ?comment (e : t) : t = | ||
match e.expression_desc with | ||
| Number _ | Length _ -> str ?comment L.js_type_number | ||
| Str _ -> str ?comment L.js_type_string | ||
| Str _ | Unicode _ -> str ?comment L.js_type_string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type of unicode is string. |
||
| Array _ -> str ?comment L.js_type_object | ||
| Bool _ -> str ?comment L.js_type_boolean | ||
| _ -> { expression_desc = Typeof e; comment } | ||
|
@@ -551,6 +551,8 @@ let rec triple_equal ?comment (e0 : t) (e1 : t) : t = | |
| Str {txt=x}, Str {txt=y} -> | ||
(* CF*) | ||
bool (Ext_string.equal x y) | ||
| Unicode x, Unicode y -> | ||
bool (Ext_string.equal x y) | ||
| Number (Int { i = i0; _ }), Number (Int { i = i1; _ }) -> bool (i0 = i1) | ||
| Optional_block (a, _), Optional_block (b, _) -> triple_equal ?comment a b | ||
| Undefined, Optional_block _ | ||
|
@@ -810,7 +812,8 @@ let uint32 ?comment n : J.expression = | |
|
||
let string_comp (cmp : J.binop) ?comment (e0 : t) (e1 : t) = | ||
match (e0.expression_desc, e1.expression_desc) with | ||
| Str {txt=a0}, Str {txt=b0} -> ( | ||
| Str {txt=a0}, Str {txt=b0} | ||
| Unicode a0, Unicode b0 -> ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Equality s1 == s2 should correspond to equal byte representation also in unicode. |
||
match cmp with | ||
| EqEqEq -> bool (a0 = b0) | ||
| NotEqEq -> bool (a0 <> b0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,7 +192,7 @@ let subst_map (substitution : J.expression Hash_ident.t) = | |
let _, e, bindings = | ||
Ext_list.fold_left ls (0, [], []) (fun (i, e, acc) x -> | ||
match x.expression_desc with | ||
| Var _ | Number _ | Str _ | J.Bool _ | Undefined -> | ||
| Var _ | Number _ | Str _ | Unicode _ | J.Bool _ | Undefined -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what enables inlining from the relevant issue linked to this PR. |
||
(* TODO: check the optimization *) | ||
(i + 1, x :: e, acc) | ||
| _ -> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,7 +220,7 @@ let record_scope_pass = | |
TODO: | ||
*) | ||
match x.expression_desc with | ||
| Fun _ | Number _ | Str _ -> state | ||
| Fun _ | Number _ | Str _ | Unicode _ -> state | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unicode strings are immutable. |
||
| _ -> | ||
(* if Set_ident.(is_empty @@ *) | ||
(* inter self#get_mutable_values *) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok to duplicate unicode strings