- (with-string string
- (let* ((left-end (if left-p
- (do ((index start (1+ index)))
- ((or (= index (the fixnum end))
- (not (find (schar string index)
- char-bag
- :test #'char=)))
- index)
- (declare (fixnum index)))
- 0))
- (right-end (if right-p
- (do ((index (1- (the fixnum end)) (1- index)))
- ((or (< index left-end)
- (not (find (schar string index)
- char-bag
- :test #'char=)))
- (1+ index))
- (declare (fixnum index)))
- (length string))))
- (if (and (eql left-end 0)
- (eql right-end (length string)))
- string
- (subseq (the simple-string string) left-end right-end)))))
+ (let ((header (%string string)))
+ (with-array-data ((string header)
+ (start)
+ (end)
+ :check-fill-pointer t)
+ (let* ((left-end (if left-p
+ (do ((index start (1+ index)))
+ ((or (= index (the fixnum end))
+ (not (find (schar string index)
+ char-bag
+ :test #'char=)))
+ index)
+ (declare (fixnum index)))
+ start))
+ (right-end (if right-p
+ (do ((index (1- (the fixnum end)) (1- index)))
+ ((or (< index left-end)
+ (not (find (schar string index)
+ char-bag
+ :test #'char=)))
+ (1+ index))
+ (declare (fixnum index)))
+ end)))
+ (if (and (eql left-end start)
+ (eql right-end end))
+ header
+ (subseq (the simple-string string) left-end right-end))))))