* optimization: compiler-internal data structure use has been
reviewed, and changes have been made that should improve the
performance of the compiler by about 20%.
+ * optimization: performance of FILL (and :INITIAL-ELEMENT) on
+ simple-base-strings and simple-bit-vectors is improved.
* microoptimization: the compiler is better able to make use of the
x86 LEA instruction for multiplication by constants.
* bug fix: in some situations compiler did not report usage of
(unless (= numx numy)
(return nil))))))))
-;;; FIXME: it is probably worth doing something like this for
-;;; SIMPLE-BASE-STRINGs too, if only so that (MAKE-STRING 100000
-;;; :INITIAL-ELEMENT #\Space) doesn't surprise the user with its
-;;; performance characteristics. Getting it right is harder than with
-;;; bit-vectors, though, as one needs to be more careful with the loop
-;;; epilogue so as not to overwrite the convenient extra null byte
-;;; (for SB-ALIEN/C termination convention convenience).
(deftransform fill ((sequence item) (simple-bit-vector bit) *
:policy (>= speed space))
(let ((value (if (constant-continuation-p item)
(declare (optimize (speed 3) (safety 0))
(type index index end-1))
(setf (%raw-bits sequence index) value))))))
+
+(deftransform fill ((sequence item) (simple-base-string base-char) *
+ :policy (>= speed space))
+ (let ((value (if (constant-continuation-p item)
+ (let* ((char (continuation-value item))
+ (code (sb!xc:char-code char)))
+ (logior code (ash code 8) (ash code 16) (ash code 24)))
+ `(let ((code (sb!xc:char-code item)))
+ (logior code (ash code 8) (ash code 16) (ash code 24))))))
+ `(let ((length (length sequence))
+ (value ,value))
+ (multiple-value-bind (times rem)
+ (truncate length 4)
+ (do ((index sb!vm:vector-data-offset (1+ index))
+ (end (+ times sb!vm:vector-data-offset)))
+ ((= index end)
+ (let ((place (* times 4)))
+ (declare (fixnum place))
+ (dotimes (j rem)
+ (declare (index j))
+ (setf (schar sequence (the index (+ place j))) item))))
+ (declare (optimize (speed 3) (safety 0))
+ (type index index))
+ (setf (%raw-bits sequence index) value))))))
\f
;;;; %BYTE-BLT