Code review comment for lp:~zorba-coders/zorba/xml-in-json-indices

Revision history for this message
Ghislain Fourny (gislenius) wrote :

> In XmlTree, there are now 2 pointers to the root node of the tree: theRootNode
> and theTreeInfo->theRoot.
> Also, theTreeInfo should be an embeded instance of CollectionTreeInfo, instead
> of being allocated every time an XmlTree is constructed.
>
> There is already an Item::isInSubtreeOf() method at the store API. Currently,
> this method applies to AnyURI items only. I think it should be extended to
> apply to structured items as well, and then the StructuredItem::isInSubtree()
> should be removed. This will make things consistent with the isAncestor,
> isChild, etc. methods, which apply to both AnyURI items and nodes.

I added an implementation of Item::isInSubtreeOf() for structured items as you requested. However, the function StructuredItem::isInSubtree() is still needed because (i) it is the other way round and in particular (ii) it is based on a structural recursion on "this" taking advantage of dynamic binding, so that the code depends on the kind of structured item.
Item::isInSubtreeOf() cannot use a structural recursion in the same way, so that it calls StructuredItem::isInSubTree() instead to avoid both (i) code replication and (ii) making structural_item.h aware of its subclasses.

Does it make sense?

« Back to merge proposal