Skip to content

Commit 4f9da0a

Browse files
committed
remove tag from EndElementEvent
this data was unused and it was set wrong
1 parent 2a202da commit 4f9da0a

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/main/clojure/clojure/data/xml/event.clj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626
attrs #(merge-nss (element-nss* element) %2)))
2727

2828
; Represents a parse event.
29-
; type is one of :start-element, :end-element, or :characters
3029
(defrecord StartElementEvent [tag attrs nss location-info])
31-
(defrecord EndElementEvent [tag])
3230
(defrecord CharsEvent [str])
3331
(defrecord CDataEvent [str])
3432
(defrecord CommentEvent [str])
3533

34+
;; EndElementEvent doesn't have any data, so make it a singleton
35+
(deftype EndElementEvent [])
36+
(def end-element-event (EndElementEvent.))
37+
(defn ->EndElementEvent [] end-element-event)
38+
3639
;; Event Generation for stuff to show up in generated xml
3740

3841
(let [second-arg #(do %2)
@@ -42,7 +45,7 @@
4245
attrs #(->StartElementEvent
4346
tag %1 (merge-nss (element-nss* element) %2) nil)))
4447
:next-events (fn elem-next-events [{:keys [tag content]} next-items]
45-
(list* content (->EndElementEvent tag) next-items))}]
48+
(list* content end-element-event next-items))}]
4649
(extend-protocol-fns
4750
EventGeneration
4851
(StartElementEvent EndElementEvent CharsEvent CDataEvent CommentEvent)
@@ -87,4 +90,4 @@
8790
:else (throw (ex-info "Illegal argument, not an event object" {:event event}))))
8891

8992
(defn event-exit? [event]
90-
(instance? EndElementEvent event))
93+
(identical? end-element-event event))

src/main/clojure/clojure/data/xml/jvm/parse.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
XMLStreamConstants/END_ELEMENT
8989
(if (include-node? :element)
9090
(do (assert (seq ns-envs) "Balanced end")
91-
(cons (->EndElementEvent (keyword (.getLocalName sreader)))
91+
(cons (->EndElementEvent)
9292
(pull-seq sreader opts (rest ns-envs))))
9393
(recur))
9494
XMLStreamConstants/CHARACTERS

0 commit comments

Comments
 (0)