src/parser/scanner-charbuf-impl.lisp: Use `replace' rather than a loop.
[sod] / src / parser / scanner-charbuf-impl.lisp
index 65f6e1e..414e1a8 100644 (file)
@@ -65,7 +65,7 @@
 
 (export 'charbuf-scanner)
 (defclass charbuf-scanner (character-scanner)
-  ((stream :initarg :stream :type stream)
+  ((%stream :initarg :stream :type stream)
    (buf :initform nil :type (or charbuf (member nil :eof)))
    (size :initform 0 :type (integer 0 #.charbuf-size))
    (index :initform 0 :type (integer 0 #.charbuf-size))
    (if we're currently rewound) or with a new buffer from the stream."))
 
 (defmethod charbuf-scanner-fetch ((scanner charbuf-scanner))
-  (with-slots (stream buf size index tail captures) scanner
+  (with-slots ((stream %stream) buf size index tail captures) scanner
     (loop
       (acond
 
   ;; Grab the filename from the underlying stream if we don't have a better
   ;; guess.
   (default-slot (scanner 'filename slot-names)
-    (with-slots (stream) scanner
+    (with-slots ((stream %stream)) scanner
       (aif (stream-pathname stream) (namestring it) nil)))
 
   ;; Get ready with the first character.
     (unless end (setf end (length seq)))
     (let ((i start) (n (- end start)))
       (labels ((copy (i buf start end)
-                (do ((j i (1+ j))
-                     (k start (1+ k)))
-                    ((>= k end))
-                  (setf (char seq j) (schar buf k))))
+                (replace seq buf :start1 i :start2 start :end2 end))
               (snarf (buf start end)
                 (let ((m (- end start)))
                   (cond ((< m n)