Permalink
Browse files

made string-builders behave like the other collectors (rather than

clearing their output after retrieving it the first time)
  • Loading branch information...
1 parent 09c0856 commit 61b2270871e12a40266363fe6eb93772029cf449 @bobbysmith007 bobbysmith007 committed Dec 20, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 collectors.lisp
View
@@ -53,7 +53,13 @@
(lambda (&rest args)
(if args
(mapc #'p args)
- (get-output-stream-string s))))))
+ ;; todo: this seems pretty hacky, but I would like to maintain the interface
+ ;; of all the other collectors (of being able to access intermediate output
+ ;; repeatedly), so for now I guess this is it. Should test to see if
+ ;; writing / coercing an array is faster or slower
+ (let ((so-far (get-output-stream-string s)))
+ (write-string so-far s)
+ so-far))))))
(defmacro with-string-builder ((name &key delimiter (ignore-empty-strings-and-nil t))
&body body)

0 comments on commit 61b2270

Please sign in to comment.