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?

Your team Zorba Coders is subscribed to branch lp:zorba.

Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to