From 5b87316b9e5691f21e8cdca3f97a2058a074ad7c Mon Sep 17 00:00:00 2001 From: Vladimir Sedach Date: Mon, 6 Jul 2009 14:13:15 -0600 Subject: [PATCH] Rewrote 'ps' macro to expand into 'with-output-to-string' instead of 'concatenate,' which gives better runtime performance. --- src/compilation-interface.lisp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compilation-interface.lisp b/src/compilation-interface.lisp index cb97cf3..0fcaa27 100644 --- a/src/compilation-interface.lisp +++ b/src/compilation-interface.lisp @@ -5,8 +5,13 @@ (defmacro ps (&body body) "Given Parenscript forms (an implicit progn), compiles those forms to a JavaScript string at macro-expansion time." - `(concatenate 'string ,@(parenscript-print (compile-parenscript-form `(progn ,@body) :expecting :statement)))) - + (let ((s (gensym))) + `(with-output-to-string (,s) + ,@(mapcar (lambda (x) + `(write-string ,x ,s)) + (parenscript-print + (compile-parenscript-form `(progn ,@body) + :expecting :statement)))))) (defun ps* (&rest body) "Compiles BODY to a JavaScript string. Body is evaluated." -- 2.20.1