From 514bde72c4a3f291221bbb362b9496c020042925 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 4 Dec 2014 19:54:04 -0500 Subject: Optimizing writes of single characters --- include/urweb/urweb_cpp.h | 2 ++ src/c/urweb.c | 4 ++++ src/mono_opt.sml | 2 ++ 3 files changed, 8 insertions(+) diff --git a/include/urweb/urweb_cpp.h b/include/urweb/urweb_cpp.h index 637cddfc..39679dd5 100644 --- a/include/urweb/urweb_cpp.h +++ b/include/urweb/urweb_cpp.h @@ -396,4 +396,6 @@ extern const char uw_begin_xhtml[], uw_begin_html5[]; int uw_remoteSock(struct uw_context *); void uw_set_remoteSock(struct uw_context *, int sock); +void uw_Basis_writec(struct uw_context *, char); + #endif diff --git a/src/c/urweb.c b/src/c/urweb.c index 1f2c8b3c..e2881b05 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -1659,6 +1659,10 @@ void uw_writec(uw_context ctx, char c) { uw_writec_unsafe(ctx, c); } +void uw_Basis_writec(uw_context ctx, char c) { + uw_writec(ctx, c); +} + static void uw_write_unsafe(uw_context ctx, const char* s) { int len = strlen(s); memcpy(ctx->page.front, s, len); diff --git a/src/mono_opt.sml b/src/mono_opt.sml index 211b273e..2d40e0f0 100644 --- a/src/mono_opt.sml +++ b/src/mono_opt.sml @@ -626,6 +626,8 @@ fun exp e = EFfiApp ("Basis", "attrifyChar", [e]) | EFfiApp ("Basis", "attrifyString_w", [((EFfiApp ("Basis", "str1", [e]), _), _)]) => EFfiApp ("Basis", "attrifyChar_w", [e]) + | EWrite (EFfiApp ("Basis", "str1", [e]), _) => + EFfiApp ("Basis", "writec", [e]) | EBinop (_, "+", (EPrim (Prim.Int n1), _), (EPrim (Prim.Int n2), _)) => EPrim (Prim.Int (Int64.+ (n1, n2))) -- cgit v1.2.3