# HG changeset patch # User Adam Chlipala # Date 1417658775 18000 # Node ID 1b76ae703cbbc43884fffc7b9be7e1351a094801 # Parent d4ed20beb93b812a882dcab02e951a2a17cb922a Some more optimization of string expressions showing up in JSON generation (Meta library) diff -r d4ed20beb93b -r 1b76ae703cbb src/mono_opt.sml --- a/src/mono_opt.sml Tue Nov 25 08:21:09 2014 -0500 +++ b/src/mono_opt.sml Wed Dec 03 21:06:15 2014 -0500 @@ -220,6 +220,11 @@ | 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 -r d4ed20beb93b -r 1b76ae703cbb src/mono_reduce.sml --- a/src/mono_reduce.sml Tue Nov 25 08:21:09 2014 -0500 +++ b/src/mono_reduce.sml Wed Dec 03 21:06:15 2014 -0500 @@ -208,6 +208,20 @@ 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