commit a6164f0bc0b2003b757f83455e79ef08fe8d7f7e Javier Olaechea <pirata@gmail.com> 2017-10-29 01:06:08 -0500 Avoid RENDERing the text of a Post twice Besides avoiding duplicate work the order in which we assign the values to the slots no longer matters as excerpt doesn't read the contents from the TEXT slot anymore. cf. https://github.com/kingcons/coleslaw/pull/129/commits/e1ab552e8f8ea679bf6e936e346694590057e752
src/posts.lisp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/posts.lisp b/src/posts.lisp index 5c25ea7..39d7f96 100644 --- a/src/posts.lisp +++ b/src/posts.lisp @@ -9,14 +9,15 @@ (defmethod initialize-instance :after ((object post) &key) (with-slots (url title author excerpt format text) object - (setf url (compute-url object (slugify title)) - format (make-keyword (string-upcase format)) - text (render-text text format) - excerpt (or excerpt - (first (split (excerpt-sep *config*) - (render-text text format) - :limit 2))) - author (or author (author *config*))))) + (let ((post-content (render-text text format))) + (setf url (compute-url object (slugify title)) + format (make-keyword (string-upcase format)) + excerpt (or excerpt + (first (split (excerpt-sep *config*) + post-content + :limit 2))) + text post-content + author (or author (author *config*)))))) (defmethod render ((object post) &key prev next) (funcall (theme-fn 'post) (list :config *config*