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

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

Hi Markos,

Thanks for your thorough analysis.

> Also, theTreeInfo should be an embeded instance of CollectionTreeInfo,
> instead of being allocated every time an XmlTree is constructed.

> But I still don't see why a CollectionTreeInfo must be heap-allocated
> every time an XmlTree is constructed.

The reason is that the CollectionTreeInfo object is not necessarily owned by the XMLTree, but it can also be shared with JSON items higher in the collection tree and possibly other XML trees that are also in the collection tree.

There are basically three cases:
(i) The XMLTree is not in a collection.
(ii) The XMLTree is in a collection and its root is also the overall collection tree root.
(iii) The XMLTree is in a collection, but the overall root is a JSON item.

If it were not for case (iii), it would have worked to embed the CollectionTreeInfo object in the class. But case (iii) is incompatible with this... The code should however only allocate/deallocate this object from the heap when switching between case (iii) and case (i).

Does it make sense?

« Back to merge proposal