Introduction
Introduction Statistics Contact Development Disclaimer Help
Improve performance by using proper functions to write string to file - cl-yag …
git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws…
Log
Files
Refs
Tags
README
LICENSE
---
commit 5e3abb608d7259d1c4acdd5be13a711fe4b49160
parent 5c2a1c9632b5d0b6b0f21fb330dc5b19bcc6b244
Author: Solene Rapenne <[email protected]>
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(-)
---
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)
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.