Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

reuse empty Attributes instance when possible #32

Merged
merged 1 commit into from

2 participants

@josharnold52

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.

@djspiewak
Owner

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
View
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.