-
-
Save senior/8a5125e7827abfbeb8d0 to your computer and use it in GitHub Desktop.
Big lazy-seq in a defrecord
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defrecord Element [tag attrs content] | |
Emit | |
(emit-element [e writer] ;;<---- e has a big lazy seq for it's :content, see below | |
(let [nspace (namespace (:tag e)) | |
qname (name (:tag e)) | |
^javax.xml.stream.XMLStreamWriter writer writer] | |
(.writeStartElement writer "" qname (or nspace "")) | |
(write-attributes e writer) | |
(doseq [c (:content e)] | |
(emit-element c writer)) | |
(.writeEndElement writer)))) | |
(Element. :some-tags | |
{} | |
(map #(Element. :foo {} [(str "foo" %)]) ;;<--- this is the :content of the tag, 10 million <foo>fooX</foo> | |
(range 0 10000000))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment