diff options
author | Adam Chlipala <adam@chlipala.net> | 2014-12-03 21:06:15 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2014-12-03 21:06:15 -0500 |
commit | c881c3b462801bc67419783c4169302fce5e3aeb (patch) | |
tree | f6fa67ac04d64173f412ca0b28f2257a03167463 /src | |
parent | b2b29ea1e208836b21842ce2126fb9fd8521247e (diff) |
Some more optimization of string expressions showing up in JSON generation (Meta library)
Diffstat (limited to 'src')
-rw-r--r-- | src/mono_opt.sml | 5 | ||||
-rw-r--r-- | src/mono_reduce.sml | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/mono_opt.sml b/src/mono_opt.sml index d1e5ce55..a49d54e1 100644 --- a/src/mono_opt.sml +++ b/src/mono_opt.sml @@ -220,6 +220,11 @@ fun exp e = | EWrite (EFfiApp ("Basis", "htmlifySpecialChar", [e]), _) => EFfiApp ("Basis", "htmlifySpecialChar_w", [e]) + | EWrite (EFfiApp ("Basis", "intToString", [e]), _) => + EFfiApp ("Basis", "htmlifyInt_w", [e]) + | EApp ((EFfi ("Basis", "intToString"), loc), e) => + EFfiApp ("Basis", "intToString", [(e, (TFfi ("Basis", "int"), loc))]) + | EFfiApp ("Basis", "htmlifyString", [((EFfiApp ("Basis", "intToString", [((EPrim (Prim.Int n), _), _)]), _), _)]) => EPrim (Prim.String (Prim.Html, htmlifyInt n)) | EFfiApp ("Basis", "htmlifyString", [((EFfiApp ("Basis", "intToString", es), _), _)]) => diff --git a/src/mono_reduce.sml b/src/mono_reduce.sml index 50553560..591d4c1b 100644 --- a/src/mono_reduce.sml +++ b/src/mono_reduce.sml @@ -208,6 +208,20 @@ fun match (env, p : pat, e : exp) = else No + | (PPrim (Prim.String (_, s)), _) => + let + fun lengthLb (e : exp) = + case #1 e of + EStrcat (e1, e2) => lengthLb e1 + lengthLb e2 + | EPrim (Prim.String (_, s)) => size s + | _ => 0 + in + if lengthLb e > size s then + No + else + Maybe + end + | (PCon (_, PConVar n1, po), ECon (_, PConVar n2, eo)) => if n1 = n2 then case (po, eo) of |