URI: 
       Improve performance by using proper functions to write string to file - cl-yag - Common Lisp Yet Another website Generator
  HTML git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 5e3abb608d7259d1c4acdd5be13a711fe4b49160
   DIR parent 5c2a1c9632b5d0b6b0f21fb330dc5b19bcc6b244
  HTML Author: Solene Rapenne <solene@perso.pw>
       Date:   Tue, 27 Aug 2019 09:07:18 +0200
       
       Improve performance by using proper functions to write string to file
       
       Diffstat:
         M generator.lisp                      |      14 +++++---------
       
       1 file changed, 5 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/generator.lisp b/generator.lisp
       @@ -100,14 +100,10 @@
        ;; we escape ~ to avoid failures with format
        (defun load-file(path)
          (if (probe-file path)
       -      (replace-all
       -       (apply #'concatenate 'string
       -              (with-open-file (stream path)
       -                (loop for line = (read-line stream nil)
       -                   while line
       -                   collect
       -                   (format nil "~a~%" line))))
       -       "~" "~~")
       +      (with-open-file (stream path)
       +        (let ((contents (make-string (file-length stream))))
       +          (read-sequence contents stream)
       +          contents))
            (progn
              (format t "ERROR : file ~a not found. Aborting~%" path)
              (quit))))
       @@ -115,7 +111,7 @@
        ;; save a string in a file
        (defun save-file(path data)
          (with-open-file (stream path :direction :output :if-exists :supersede)
       -                  (format stream data)))
       +                  (write-sequence data stream)))
        
        ;; simplify the str replace work
        (defmacro template(before &body after)