comparison src/mono_opt.sml @ 331:41458a694575

Optimize immediate writes of query results
author Adam Chlipala <adamc@hcoop.net>
date Sat, 13 Sep 2008 10:44:58 -0400
parents 132416711463
children 9601c717d2f3
comparison
equal deleted inserted replaced
330:f307cdd08d81 331:41458a694575
278 optExp (ECase (discE, 278 optExp (ECase (discE,
279 map (fn (p, e) => (p, (EWrite e, loc))) pes, 279 map (fn (p, e) => (p, (EWrite e, loc))) pes,
280 {disc = disc, 280 {disc = disc,
281 result = (TRecord [], loc)}), loc) 281 result = (TRecord [], loc)}), loc)
282 282
283 | EWrite (EQuery {exps, tables, state, query,
284 initial = (EPrim (Prim.String ""), _),
285 body = (EStrcat ((EPrim (Prim.String s), _),
286 (EStrcat ((ERel 0, _),
287 e'), _)), _)}, loc) =>
288 if CharVector.all Char.isSpace s then
289 EQuery {exps = exps, tables = tables, query = query,
290 state = (TRecord [], loc),
291 initial = (ERecord [], loc),
292 body = (optExp (EWrite e', loc), loc)}
293 else
294 e
295
283 | _ => e 296 | _ => e
284 297
285 and optExp e = #1 (U.Exp.map {typ = typ, exp = exp} e) 298 and optExp e = #1 (U.Exp.map {typ = typ, exp = exp} e)
286 299
287 val optimize = U.File.map {typ = typ, exp = exp, decl = decl} 300 val optimize = U.File.map {typ = typ, exp = exp, decl = decl}