- collect (if (and (stringp value)
- (< (length value) *concatenate-open-code-limit*))
- ;; Fold the array reads for constant arguments
- `(progn
- ,@(loop for c across value
- for i from 0
- collect
- ;; Without truly-the we get massive numbers
- ;; of pointless error traps.
- `(setf (aref .string.
- (truly-the index (+ .pos. ,i)))
- ,c))
- (incf .pos. ,(length value)))
- `(sb!impl::string-dispatch
- (#!+sb-unicode
- (simple-array character (*))
- (simple-array base-char (*))
- t)
- ,var
- (replace .string. ,var :start1 .pos.)
- (incf .pos. (length ,var)))))
+ collect
+ (cond ((and (stringp value)
+ (< (length value) *concatenate-open-code-limit*))
+ ;; Fold the array reads for constant arguments
+ `(progn
+ ,@(loop for c across value
+ for i from 0
+ collect
+ ;; Without truly-the we get massive numbers
+ ;; of pointless error traps.
+ `(setf (aref .string.
+ (truly-the index ,(if first-constants
+ i
+ `(+ .pos. ,i))))
+ ,c))
+ ,(unless first-constants
+ `(incf (truly-the index .pos.) ,(length value)))))
+ (t
+ (prog1
+ `(sb!impl::string-dispatch
+ (#!+sb-unicode
+ (simple-array character (*))
+ (simple-array base-char (*))
+ t)
+ ,var
+ (replace .string. ,var
+ ,@(cond ((not first-constants)
+ '(:start1 .pos.))
+ ((plusp non-constant-start)
+ `(:start1 ,non-constant-start))))
+ (incf (truly-the index .pos.) (length ,var)))
+ (setf first-constants nil)))))