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

Re: Best way to convert inte

Subject:   RE>Best way to convert integer to st
Wow, 96 bytes per string.  Each time you execute this you're creating a new
string; so, the obvious alternative is to reuse the string.  You could create a
string w/ a fill-pointer and pass that to format.  (This suggestion assumes that
you need the string or find it convenient to have it.)

(defun test (n string)
  (setf (fill-pointer string) 0)
  (format string "~D" n))

(time (let ((string (make-array 4 :element-type 'character :fill-pointer 0)))
  (dotimes (i 1000) (test 123 string))))
(I 1000) (TEST 123 STRING))) took 364 milliseconds (0.364 seconds) to run.
Of that, 45 milliseconds (0.045 seconds) were spent in The Cooperative
Multitasking Experience.
 48 bytes of memory allocated.

Date: 2/15/95 7:11 AM
To: Don Mitchell
From: Peter Stone
(time (dotimes (i 1000) (princ-to-string 123)))


 Donald H. Mitchell             Domain:  dhm@pro-solution.com
 Proactive Solutions Inc.         UUCP:  uunet!proact!dhm   
 5314 S. Yale Ave., Suite 402    Voice:  918.497.2330
 Tulsa, OK  74135                  FAX:  918.497.2323