dvreeze / tqa

XBRL Taxonomy Query API
Apache License 2.0
6 stars 3 forks source link

tqa-0001 TaxonomyElem creation too expensive for SaxonElem backing element #2

Closed dvreeze closed 3 years ago

dvreeze commented 4 years ago

Recursive TaxonomyElem creation looks at the parent element to distinguish between global and local element declarations, for example. The way the parent element is determined is not through a call to method parentOption, but through a call to method reverseAncestryOrSelfENames instead. The latter is optimal if the backing element is a native yaidom indexed element, but quite inefficient (and generating lots of garbage) for Saxon wrapper elements. This should be fixed.

The fix could be twofold:

About the second point: we could have an (internal) element query API extension API, one "instanceof" pattern match for well-known backing element implementations, and then type-safe implementations of that query API extension for those element implementations. One method in that extension query API could be "hasParentWithName(ename)", and it would have quite different implementations for Saxon wrappers and native yaidom indexed elements.

This could all be done in TQA (no need to change yaidom), without any breaking changes.

dvreeze commented 3 years ago

This was fixed in version 0.9.0, by the first proposed solution of passing the parent around in private factory methods.

dvreeze commented 3 years ago

See above.