diff 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
line wrap: on
line diff
--- a/src/mono_opt.sml	Sat Sep 13 10:33:30 2008 -0400
+++ b/src/mono_opt.sml	Sat Sep 13 10:44:58 2008 -0400
@@ -280,6 +280,19 @@
                        {disc = disc,
                         result = (TRecord [], loc)}), loc)
 
+      | EWrite (EQuery {exps, tables, state, query,
+                        initial = (EPrim (Prim.String ""), _),
+                        body = (EStrcat ((EPrim (Prim.String s), _),
+                                         (EStrcat ((ERel 0, _),
+                                                   e'), _)), _)}, loc) =>
+        if CharVector.all Char.isSpace s then
+            EQuery {exps = exps, tables = tables, query = query,
+                    state = (TRecord [], loc),
+                    initial = (ERecord [], loc),
+                    body = (optExp (EWrite e', loc), loc)}
+        else
+            e
+
       | _ => e
 
 and optExp e = #1 (U.Exp.map {typ = typ, exp = exp} e)