X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fsymbol.lisp;h=fe29dd6bc17f0a453cb7e44956bc34271bc66f1b;hb=1463431b1efcc020533afeaa68d99dc70fb93f89;hp=c95370fa7753ac1dcd764e1183d7fa08b194e8fe;hpb=79a8e51bf4b06a5bd57bc90233605f98fee3b041;p=sbcl.git diff --git a/src/code/symbol.lisp b/src/code/symbol.lisp index c95370f..fe29dd6 100644 --- a/src/code/symbol.lisp +++ b/src/code/symbol.lisp @@ -246,6 +246,11 @@ distinct from the global value. Can also be SETF." ;;;; GENSYM and friends +(defun %make-symbol-name (prefix counter) + (with-output-to-string (s) + (write-string prefix s) + (%output-integer-in-base counter 10 s))) + (defvar *gensym-counter* 0 #!+sb-doc "counter for generating unique GENSYM symbols") @@ -264,7 +269,7 @@ distinct from the global value. Can also be SETF." (let ((new (etypecase old (index (1+ old)) (unsigned-byte (1+ old))))) - (declare (optimize (speed 3) (safety 0)(inhibit-warnings 3))) + (declare (optimize (speed 3) (safety 0) (inhibit-warnings 3))) (setq *gensym-counter* new))) (multiple-value-bind (prefix int) (etypecase thing @@ -272,10 +277,7 @@ distinct from the global value. Can also be SETF." (fixnum (values "G" thing)) (string (values (coerce thing 'simple-string) old))) (declare (simple-string prefix)) - (make-symbol - (concatenate 'simple-string prefix - (the simple-string - (quick-integer-to-string int))))))) + (make-symbol (%make-symbol-name prefix int))))) (defvar *gentemp-counter* 0) (declaim (type unsigned-byte *gentemp-counter*)) @@ -284,11 +286,6 @@ distinct from the global value. Can also be SETF." #!+sb-doc "Creates a new symbol interned in package PACKAGE with the given PREFIX." (declare (type string prefix)) - (loop - (let ((*print-base* 10) - (*print-radix* nil) - (*print-pretty* nil) - (new-pname (format nil "~A~D" prefix (incf *gentemp-counter*)))) - (multiple-value-bind (symbol existsp) (find-symbol new-pname package) - (declare (ignore symbol)) - (unless existsp (return (values (intern new-pname package)))))))) + (loop for name = (%make-symbol-name prefix (incf *gentemp-counter*)) + while (nth-value 1 (find-symbol name package)) + finally (return (values (intern name package)))))