Home | News | Documentation | Download

TClonesArray: Expand vs. ExpandCreate

While I think I understand the difference between the Expand and the ExpandCreate mehods of TClonesArray, I can’t really understand the benefits of one respect to the other.

  1. Expand will just create the space in the TClonesArray internals for the pointers to the new elements but will not allocate the space for the elements themselves. The latters will be allocated e.g. on first access using operator[]
  2. ExpandCreate behaves like Expand, but it also allocates memory for the elements

Since in both scenarios the elements are allocated one by one then I guess that there is no major difference regarding the allocation efficiency and thus the speed, right? Also, in both approaches the elements are initialized calling the default constructor, so in the end also the content should be the same, right?