comparison src/mono_opt.sml @ 183:c0ea24dcb86f

Optimizing 'case' in Mono_reduce
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 13:30:27 -0400
parents b1cfe49ce692
children 98c29e3986d3
comparison
equal deleted inserted replaced
182:d11754ffe252 183:c0ea24dcb86f
77 val urlifyString = String.translate (fn #" " => "+" 77 val urlifyString = String.translate (fn #" " => "+"
78 | ch => if Char.isAlphaNum ch then 78 | ch => if Char.isAlphaNum ch then
79 str ch 79 str ch
80 else 80 else
81 "%" ^ hexIt ch) 81 "%" ^ hexIt ch)
82 82
83 fun exp e = 83 fun exp e =
84 case e of 84 case e of
85 EPrim (Prim.String s) => 85 EPrim (Prim.String s) =>
86 let 86 let
87 val (_, chs) = 87 val (_, chs) =
129 optExp (EStrcat (e1, (EStrcat (e2, e3), loc)), loc) 129 optExp (EStrcat (e1, (EStrcat (e2, e3), loc)), loc)
130 130
131 | EWrite (EStrcat (e1, e2), loc) => 131 | EWrite (EStrcat (e1, e2), loc) =>
132 ESeq ((optExp (EWrite e1, loc), loc), 132 ESeq ((optExp (EWrite e1, loc), loc),
133 (optExp (EWrite e2, loc), loc)) 133 (optExp (EWrite e2, loc), loc))
134
135 | ESeq ((EWrite (EPrim (Prim.String s1), _), loc),
136 (EWrite (EPrim (Prim.String s2), _), _)) =>
137 EWrite (EPrim (Prim.String (s1 ^ s2)), loc)
134 138
135 | EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]) => 139 | EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]) =>
136 EPrim (Prim.String (htmlifyString s)) 140 EPrim (Prim.String (htmlifyString s))
137 | EWrite (EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]), loc) => 141 | EWrite (EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]), loc) =>
138 EWrite (EPrim (Prim.String (htmlifyString s)), loc) 142 EWrite (EPrim (Prim.String (htmlifyString s)), loc)