From: Vladimir Sedach Date: Mon, 6 Jul 2009 20:13:15 +0000 (-0600) Subject: Rewrote 'ps' macro to expand into 'with-output-to-string' instead of X-Git-Url: https://git.hcoop.net/clinton/parenscript.git/commitdiff_plain/5b87316b9e5691f21e8cdca3f97a2058a074ad7c Rewrote 'ps' macro to expand into 'with-output-to-string' instead of 'concatenate,' which gives better runtime performance. --- 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."