-
Notifications
You must be signed in to change notification settings - Fork 469
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
Conversation
These are the same as for strings, except indexing. Fixes #5454
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.
Checked the various cases and added comments.
@@ -268,6 +270,6 @@ let rev_toplevel_flatten block = | |||
|
|||
let rec is_okay_to_duplicate (e : J.expression) = | |||
match e.expression_desc with | |||
| Var _ | Bool _ | Str _ | Number _ -> true | |||
| Var _ | Bool _ | Str _ | Unicode _ | Number _ -> true |
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
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like same behaviour as strings: both pure.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Type of unicode is string.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Equality s1 == s2 should correspond to equal byte representation also in unicode.
@@ -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 comment
The 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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Unicode strings are immutable.
These are the same as for strings, except indexing.
Fixes #5454