[jdom-interest] AttributeList performance
eross at m-qube.com
Thu Apr 28 14:27:11 PDT 2005
On Thu, 2005-04-28 at 13:21 -0700, Tatu Saloranta wrote:
> As to the access time itself, I'm fairly confident
> that the HashMap solution is pretty much always faster
> for even fairly small sets (3 or more entries).
> But the performance benefit of just the access itself
> has to outweigh memory and speed overheads of creating
> HashMap which is more heavy-weight than a simple
It's pretty hard to come up with a solution that satisfies the
degenerate case (Elements with lots of attributes) and the common case
(one or two attributes.)
I suggested sorting the attributes and doing a binary search would be
okay, but it seemed not terribly popular.
One solution would be to add a protected constructor or factory to
Element that would allow an alternative attribute list implementation to
be specified. Then, clients could create their own DOMBuilder which
returns Elements with this new attribute class. This isn't exactly
clean either, but might be good enough.
If it were my application, I would simply "fork" the code and build my
own library instead. Then, I'd send the patches to jdom and leave it at
More information about the jdom-interest