Skip to content

Commit

Permalink
Refactor: avoid an unnecessary runtime check in some situations
Browse files Browse the repository at this point in the history
  • Loading branch information
luontola committed Dec 1, 2023
1 parent 34a1656 commit 95a8b0f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/hiccup/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,12 @@
~(end-tag)))
(build-string ~(str "<" tag (render-attr-map tag-attrs) ">")
~@(compile-seq [attrs-sym])))
;; content and ending tag (when the above code did not emit an ending tag)
(when (or ~(boolean (container-tag? tag content))
(not (map? ~attrs-sym)))
(build-string ~@(compile-seq content)
~(str "</" tag ">")))))))
~@(compile-seq content)
;; ending tag, when the above code did not emit an ending tag
~(if (container-tag? tag content)
(str "</" tag ">")
`(when-not (map? ~attrs-sym)
~(str "</" tag ">")))))))

(defmethod compile-element :default
[element]
Expand Down

0 comments on commit 95a8b0f

Please sign in to comment.