Rewrote 'ps' macro to expand into 'with-output-to-string' instead of
authorVladimir Sedach <vsedach@gmail.com>
Mon, 6 Jul 2009 20:13:15 +0000 (14:13 -0600)
committerVladimir Sedach <vsedach@gmail.com>
Mon, 6 Jul 2009 20:13:15 +0000 (14:13 -0600)
'concatenate,' which gives better runtime performance.

src/compilation-interface.lisp

index cb97cf3..0fcaa27 100644 (file)
@@ -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."