[jdom-interest] JDOM && Jaxen

Jason Hunter jhunter at acm.org
Wed Aug 1 12:06:36 PDT 2001

bob mcwhirter wrote:
> Yah, even without getParent(), though, not using flyweights on the
> Namespaces would help.

Really, why?

> In a given document, how many times do you typically see the exactly
> same namespace decl?  Is it worth the overhead of flyweighting them?

JDOM stores namespaces in each element (so when they move they keep
their namespace).  This means it's not just the decls that matter. 
Imagine a namespace-aware document with 10,000 elements in 3
namespaces... With the current model you'll have 3 Namespace instances. 
With a non-flyweight you'll have between 3 and 10,000 depending on
usage.  And with a non-flyweight with parents, you'll for sure have
10,000.  The reason the middle choice varies is that if the builder
(class or programmer) is at all smart, they can reuse namespace
instances with a private factory instead of the public one used now.  If
parentage must be retained, no reuse is possible.


More information about the jdom-interest mailing list