[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fast string and number output to a stream



In article <Cqtnpx.90J@cc.umontreal.ca>, kardank@ERE.UMontreal.CA (Kardan
Kaveh) wrote:

> What is the fastest way of writing strings and numbers to a stream?  None
> of the ways I have tried seems to be much faster than simply using format.
> 
For Strings
(defun save-a-string (string function value stream)
  (declare (ignore stream))
  (dovector (char string)
    (when (char= char #\")
      (funcall function value #\\))
    (funcall function value char)
    )
  )


(defun save-a-string-to-an-open-stream (string stream)
  (multiple-value-bind
    (a b)
    (stream-writer stream)
    (save-a-string string a b stream)))


;(save-a-string-to-an-open-stream "ddddd" *standard-output*)

I have something like this for fixnums too, but you might as well call
print-object for numbers

Karsten