@@ -77,7 +77,15 @@ namespace {
7777 if (fOnfileObject ) fBuffer .PopDataCache ();
7878 }
7979 };
80- bool IsAssociativeContainer (Int_t stltype) {
80+ // //////////////////////////////////////////////////////////////////////////////
81+ // / Check if a collection proxy represents an associative collection (e.g., std::map, std::set)
82+ // / rather than a sequential collection (e.g., std::vector, std::list).
83+ // / Both the version based on the fSTLtype integer and the one based on the TVirtualCollectionProxy
84+ // / will return the same result about the 'currently' in memory collection attached to the branch.
85+ // / The main difference is that the fSTLtype can be used without checking whether
86+ // / fCollProxy is set or not but might (or might not) be a tad bit slower.
87+ bool IsAssociativeContainer (Int_t stltype)
88+ {
8189 switch (stltype) {
8290 case ROOT::kSTLset :
8391 case ROOT::kSTLmultiset :
@@ -92,6 +100,11 @@ namespace {
92100 return false ;
93101 }
94102 }
103+ bool IsAssociativeContainer (const TVirtualCollectionProxy &proxy)
104+ {
105+ return proxy.GetProperties () & TVirtualCollectionProxy::kIsAssociative ;
106+ }
107+
95108 void RecursiveResetReadEntry (TBranch *br)
96109 {
97110 br->ResetReadEntry ();
@@ -1475,7 +1488,7 @@ void TBranchElement::FillLeavesCollection(TBuffer& b)
14751488 // NOTE: this does not work for not vectors since the CreateIterators expects a TGenCollectionProxy::TStaging as its argument!
14761489 // NOTE: and those not work in general yet, since the TStaging object is neither created nor passed.
14771490 // We need to review how to avoid the need for a TStaging during the writing.
1478- if (proxy-> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
1491+ if (IsAssociativeContainer (*proxy) ) {
14791492 fWriteIterators ->CreateIterators (fObject , proxy);
14801493 } else {
14811494 fIterators ->CreateIterators (fObject , proxy);
@@ -4346,7 +4359,7 @@ void TBranchElement::ReadLeavesCollection(TBuffer& b)
43464359 fIterators ->CreateIterators (alternate, proxy);
43474360 }
43484361
4349- if (IsAssociativeContainer (fSTLtype )) {
4362+ if (IsAssociativeContainer (*proxy )) {
43504363
43514364 Int_t nbranches = fBranches .GetEntriesFast ();
43524365 for (Int_t i = 0 ; i < nbranches; ++i) {
@@ -5141,7 +5154,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
51415154
51425155 if (fSTLtype != ROOT::kSTLvector && fCollProxy ->HasPointers () && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
51435156 fPtrIterators = new TVirtualCollectionPtrIterators (fCollProxy );
5144- } else if (fCollProxy -> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5157+ } else if (IsAssociativeContainer (* fCollProxy ) ) {
51455158 fWriteIterators = new TVirtualCollectionIterators (fCollProxy ,false );
51465159 fIterators = new TVirtualCollectionIterators (fCollProxy );
51475160 } else {
@@ -5183,7 +5196,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
51835196 delete fPtrIterators ;
51845197 if (fSTLtype != ROOT::kSTLvector && fCollProxy ->HasPointers () && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
51855198 fPtrIterators = new TVirtualCollectionPtrIterators (fCollProxy );
5186- } else if (fCollProxy -> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5199+ } else if (IsAssociativeContainer (* fCollProxy ) ) {
51875200 fWriteIterators = new TVirtualCollectionIterators (fCollProxy ,false );
51885201 fIterators = new TVirtualCollectionIterators (fCollProxy );
51895202 } else {
@@ -5219,7 +5232,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
52195232 delete fPtrIterators ;
52205233 if (fSTLtype != ROOT::kSTLvector && fCollProxy ->HasPointers () && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
52215234 fPtrIterators = new TVirtualCollectionPtrIterators (fCollProxy );
5222- } else if (fCollProxy -> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5235+ } else if (IsAssociativeContainer (* fCollProxy ) ) {
52235236 fWriteIterators = new TVirtualCollectionIterators (fCollProxy ,false );
52245237 fIterators = new TVirtualCollectionIterators (fCollProxy );
52255238 } else {
@@ -5289,7 +5302,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
52895302 if (!fIterators && !fPtrIterators ) {
52905303 if (fSTLtype != ROOT::kSTLvector && GetCollectionProxy ()->HasPointers () && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
52915304 fPtrIterators = new TVirtualCollectionPtrIterators (GetCollectionProxy ());
5292- } else if (fCollProxy -> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5305+ } else if (IsAssociativeContainer (* fCollProxy ) ) {
52935306 fWriteIterators = new TVirtualCollectionIterators (fCollProxy ,false );
52945307 fIterators = new TVirtualCollectionIterators (fCollProxy );
52955308 } else {
@@ -5862,7 +5875,7 @@ void TBranchElement::SetFillLeavesPtr()
58625875 } else {
58635876 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionSplitPtrMember;
58645877 }
5865- } else if (GetCollectionProxy ()-> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5878+ } else if (IsAssociativeContainer (* GetCollectionProxy ()) ) {
58665879 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesAssociativeCollectionMember;
58675880 } else {
58685881 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionMember;
0 commit comments