aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-09-13 10:44:58 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-09-13 10:44:58 -0400
commitfd2079464d7b65430af09f2734fa55039006a3e3 (patch)
treea82ea4c81cadfae6a2692d0004068301cb57aa5e
parent83f4f01d3475248237bfea2e01d6e007c23153ff (diff)
Optimize immediate writes of query results
-rw-r--r--src/cjr_print.sml2
-rw-r--r--src/mono_opt.sml13
-rw-r--r--src/mono_print.sml10
3 files changed, 19 insertions, 6 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index c235d2a2..b90854a1 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -745,7 +745,7 @@ fun p_exp' par env (e, loc) =
in
box [string "(uw_begin_region(ctx), ",
if wontLeakAnything then
- string "uw_begin_regio(ctx), "
+ string "uw_begin_region(ctx), "
else
box [],
string "({",
diff --git a/src/mono_opt.sml b/src/mono_opt.sml
index 373f5b27..64eef7e3 100644
--- a/src/mono_opt.sml
+++ b/src/mono_opt.sml
@@ -280,6 +280,19 @@ fun exp e =
{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)
diff --git a/src/mono_print.sml b/src/mono_print.sml
index 0b85e1c4..40abf7d7 100644
--- a/src/mono_print.sml
+++ b/src/mono_print.sml
@@ -193,11 +193,11 @@ fun p_exp' par env (e, _) =
p_typ env t,
string ")"]
- | EStrcat (e1, e2) => box [p_exp' true env e1,
- space,
- string "^",
- space,
- p_exp' true env e2]
+ | EStrcat (e1, e2) => parenIf par (box [p_exp' true env e1,
+ space,
+ string "^",
+ space,
+ p_exp env e2])
| EWrite e => box [string "write(",
p_exp env e,