Micro-optimize (ice-9 format).
authorLudovic Courtès <ludo@gnu.org>
Mon, 20 Aug 2012 22:36:50 +0000 (00:36 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 20 Aug 2012 22:36:50 +0000 (00:36 +0200)
* module/ice-9/format.scm (format): Use `call-with-output-string'
  instead of `with-output-to-string'.

module/ice-9/format.scm

index d038ace..eed8cbb 100644 (file)
                      (case modifier
                        ((at)
                         (format:out-str
-                         (with-output-to-string 
-                           (lambda ()
-                             (truncated-print (next-arg)
+                         (call-with-output-string
+                           (lambda (p)
+                             (truncated-print (next-arg) p
                                               #:width width)))))
                        ((colon-at)
                         (format:out-str
-                         (with-output-to-string 
-                           (lambda ()
-                             (truncated-print (next-arg)
+                         (call-with-output-string
+                           (lambda (p)
+                             (truncated-print (next-arg) p
                                               #:width
                                               (max (- width
                                                       output-col)
     (define (format:obj->str obj slashify)
       (let ((res (if slashify
                      (object->string obj)
-                     (with-output-to-string (lambda () (display obj))))))
+                     (call-with-output-string (lambda (p) (display obj p))))))
         (if (and format:read-proof (string-prefix? "#<" res))
             (object->string res)
             res)))