Skip to content


Subversion checkout URL

You can clone with
Download ZIP


reuse empty Attributes instance when possible #32

merged 1 commit into from

2 participants


This is a silly little tweak, but it resulted in a 6% improvement in the memory-usage reported by the loadSmall and loadLarge trials. Elements with empty Attributes should be common, so I suspect those aren't isolated cases.

I happened upon this while taking a stab at issue #19, but this seems like a worthwhile change in itself.


Wow, 6%?! That's crazy. Merging!

@djspiewak djspiewak merged commit 41e79aa into djspiewak:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 22, 2011
  1. @josharnold52
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/main/scala/com/codecommit/antixml/Attributes.scala
4 src/main/scala/com/codecommit/antixml/Attributes.scala
@@ -156,7 +156,7 @@ object Attributes {
def newBuilder = HashMap.newBuilder[QName, String] mapResult { m: Map[QName, String] => new Attributes(m) }
- val empty = apply()
+ val empty = new Attributes(Map())
- def apply(attrs: (QName, String)*) = new Attributes(Map(attrs: _*))
+ def apply(attrs: (QName, String)*) = if (attrs.isEmpty) empty else new Attributes(Map(attrs: _*))
Something went wrong with that request. Please try again.