# HG changeset patch # User Adam Chlipala # Date 1221317098 14400 # Node ID 41458a694575186a14053940449dd231f9eb7528 # Parent f307cdd08d818a3071325f83a20f7594782bf081 Optimize immediate writes of query results diff -r f307cdd08d81 -r 41458a694575 src/cjr_print.sml --- a/src/cjr_print.sml Sat Sep 13 10:33:30 2008 -0400 +++ b/src/cjr_print.sml Sat Sep 13 10:44:58 2008 -0400 @@ -745,7 +745,7 @@ in box [string "(uw_begin_region(ctx), ", if wontLeakAnything then - string "uw_begin_regio(ctx), " + string "uw_begin_region(ctx), " else box [], string "({", diff -r f307cdd08d81 -r 41458a694575 src/mono_opt.sml --- 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) diff -r f307cdd08d81 -r 41458a694575 src/mono_print.sml --- a/src/mono_print.sml Sat Sep 13 10:33:30 2008 -0400 +++ b/src/mono_print.sml Sat Sep 13 10:44:58 2008 -0400 @@ -193,11 +193,11 @@ 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,