# HG changeset patch # User Adam Chlipala # Date 1417740844 18000 # Node ID fd6d362666c01f6b38bad9b9b4a5e3515161d5a2 # Parent 0d48cfb59b29b3f6b4fcbec02977de14692eaa92 Optimizing writes of single characters diff -r 0d48cfb59b29 -r fd6d362666c0 include/urweb/urweb_cpp.h --- a/include/urweb/urweb_cpp.h Thu Dec 04 02:47:24 2014 -0500 +++ b/include/urweb/urweb_cpp.h Thu Dec 04 19:54:04 2014 -0500 @@ -396,4 +396,6 @@ 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 -r 0d48cfb59b29 -r fd6d362666c0 src/c/urweb.c --- a/src/c/urweb.c Thu Dec 04 02:47:24 2014 -0500 +++ b/src/c/urweb.c Thu Dec 04 19:54:04 2014 -0500 @@ -1659,6 +1659,10 @@ 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 -r 0d48cfb59b29 -r fd6d362666c0 src/mono_opt.sml --- a/src/mono_opt.sml Thu Dec 04 02:47:24 2014 -0500 +++ b/src/mono_opt.sml Thu Dec 04 19:54:04 2014 -0500 @@ -626,6 +626,8 @@ 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)))