[jdom-interest] AttributeList performance
schulz at videotron.ca
Sun Apr 24 11:12:55 PDT 2005
Elliotte Harold wrote:
> Martin Schulz wrote:
>> We now face the choice to
>> a) speed up JDOM internally
>> b) subclass AttributeList and implement it more efficiently
>> c) build a HashMap from the AttributeList externally
>> d) not use Element attributes for this purpose
> I suggest option b.
Interesting. I guess I'll have to subclass Element then too.
What is the factory model of JDOM and how can I be sure that
my Element subclass is being used throughout?
I guess that's a trick question...
>> Being naive about XML, my first question is whether the order of
>> attributes is either significant or within JDOM guaranteed to be stable
>> as part of any API contract, or is it considered a 'nice-to-have'?
> The order is absolutely insignificant and in no way guaranteed. This
> is an XML-level issue, not a JDOM one.
>> There might well be an implementation trade-off where the current
>> default (array of 5 Attributes)
>> is the better choice compared to adding a datastructure with a bigger
>> footprint, so I'd
>> be curious about what others might deem appropriate in this situation.
> My strong suspicion is that in the more normal use cases where
> elements have half a dozen attributes at most, or less, ArrayLists are
> much more efficient than HashMaps. You may have crossed the threshold
> where the bigger constant factor of a HashMap vs. a list makes the
> HashMap faster, so a custom subclass might make sense for you.
> However, I doubt it makes sense for the majority of users.
I totally agree... thinking of implementing of some threshold for that.
More information about the jdom-interest