comparison src/mono_reduce.sml @ 2082:1b76ae703cbb

Some more optimization of string expressions showing up in JSON generation (Meta library)
author Adam Chlipala <adam@chlipala.net>
date Wed, 03 Dec 2014 21:06:15 -0500
parents 04d7d563a36f
children 0d48cfb59b29
comparison
equal deleted inserted replaced
2081:d4ed20beb93b 2082:1b76ae703cbb
205 | (PPrim p, EPrim p') => 205 | (PPrim p, EPrim p') =>
206 if Prim.equal (p, p') then 206 if Prim.equal (p, p') then
207 Yes env 207 Yes env
208 else 208 else
209 No 209 No
210
211 | (PPrim (Prim.String (_, s)), _) =>
212 let
213 fun lengthLb (e : exp) =
214 case #1 e of
215 EStrcat (e1, e2) => lengthLb e1 + lengthLb e2
216 | EPrim (Prim.String (_, s)) => size s
217 | _ => 0
218 in
219 if lengthLb e > size s then
220 No
221 else
222 Maybe
223 end
210 224
211 | (PCon (_, PConVar n1, po), ECon (_, PConVar n2, eo)) => 225 | (PCon (_, PConVar n1, po), ECon (_, PConVar n2, eo)) =>
212 if n1 = n2 then 226 if n1 = n2 then
213 case (po, eo) of 227 case (po, eo) of
214 (NONE, NONE) => Yes env 228 (NONE, NONE) => Yes env