@@ -77,6 +77,13 @@ namespace {
77
77
if (fOnfileObject ) fBuffer .PopDataCache ();
78
78
}
79
79
};
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.
80
87
bool IsAssociativeContainer (Int_t stltype) {
81
88
switch (stltype) {
82
89
case ROOT::kSTLset :
@@ -92,6 +99,11 @@ namespace {
92
99
return false ;
93
100
}
94
101
}
102
+ bool IsAssociativeContainer (const TVirtualCollectionProxy &proxy)
103
+ {
104
+ return proxy.GetProperties () & TVirtualCollectionProxy::kIsAssociative ;
105
+ }
106
+
95
107
void RecursiveResetReadEntry (TBranch *br) {
96
108
br->ResetReadEntry ();
97
109
for (auto sub : *br->GetListOfBranches ())
@@ -1474,7 +1486,7 @@ void TBranchElement::FillLeavesCollection(TBuffer& b)
1474
1486
// NOTE: this does not work for not vectors since the CreateIterators expects a TGenCollectionProxy::TStaging as its argument!
1475
1487
// NOTE: and those not work in general yet, since the TStaging object is neither created nor passed.
1476
1488
// We need to review how to avoid the need for a TStaging during the writing.
1477
- if (proxy-> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
1489
+ if (IsAssociativeContainer (*proxy) ) {
1478
1490
fWriteIterators ->CreateIterators (fObject , proxy);
1479
1491
} else {
1480
1492
fIterators ->CreateIterators (fObject , proxy);
@@ -4344,7 +4356,7 @@ void TBranchElement::ReadLeavesCollection(TBuffer& b)
4344
4356
fIterators ->CreateIterators (alternate, proxy);
4345
4357
}
4346
4358
4347
- if (IsAssociativeContainer (fSTLtype )) {
4359
+ if (IsAssociativeContainer (*proxy )) {
4348
4360
4349
4361
Int_t nbranches = fBranches .GetEntriesFast ();
4350
4362
for (Int_t i = 0 ; i < nbranches; ++i) {
@@ -5139,7 +5151,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
5139
5151
5140
5152
if (fSTLtype != ROOT::kSTLvector && fCollProxy ->HasPointers () && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
5141
5153
fPtrIterators = new TVirtualCollectionPtrIterators (fCollProxy );
5142
- } else if (fCollProxy -> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5154
+ } else if (IsAssociativeContainer (* fCollProxy ) ) {
5143
5155
fWriteIterators = new TVirtualCollectionIterators (fCollProxy ,false );
5144
5156
fIterators = new TVirtualCollectionIterators (fCollProxy );
5145
5157
} else {
@@ -5181,7 +5193,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
5181
5193
delete fPtrIterators ;
5182
5194
if (fSTLtype != ROOT::kSTLvector && fCollProxy ->HasPointers () && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
5183
5195
fPtrIterators = new TVirtualCollectionPtrIterators (fCollProxy );
5184
- } else if (fCollProxy -> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5196
+ } else if (IsAssociativeContainer (* fCollProxy ) ) {
5185
5197
fWriteIterators = new TVirtualCollectionIterators (fCollProxy ,false );
5186
5198
fIterators = new TVirtualCollectionIterators (fCollProxy );
5187
5199
} else {
@@ -5217,7 +5229,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
5217
5229
delete fPtrIterators ;
5218
5230
if (fSTLtype != ROOT::kSTLvector && fCollProxy ->HasPointers () && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
5219
5231
fPtrIterators = new TVirtualCollectionPtrIterators (fCollProxy );
5220
- } else if (fCollProxy -> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5232
+ } else if (IsAssociativeContainer (* fCollProxy ) ) {
5221
5233
fWriteIterators = new TVirtualCollectionIterators (fCollProxy ,false );
5222
5234
fIterators = new TVirtualCollectionIterators (fCollProxy );
5223
5235
} else {
@@ -5287,7 +5299,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
5287
5299
if (!fIterators && !fPtrIterators ) {
5288
5300
if (fSTLtype != ROOT::kSTLvector && GetCollectionProxy ()->HasPointers () && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
5289
5301
fPtrIterators = new TVirtualCollectionPtrIterators (GetCollectionProxy ());
5290
- } else if (fCollProxy -> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5302
+ } else if (IsAssociativeContainer (* fCollProxy ) ) {
5291
5303
fWriteIterators = new TVirtualCollectionIterators (fCollProxy ,false );
5292
5304
fIterators = new TVirtualCollectionIterators (fCollProxy );
5293
5305
} else {
@@ -5860,7 +5872,7 @@ void TBranchElement::SetFillLeavesPtr()
5860
5872
} else {
5861
5873
fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionSplitPtrMember;
5862
5874
}
5863
- } else if (GetCollectionProxy ()-> GetProperties () & TVirtualCollectionProxy:: kIsAssociative ) {
5875
+ } else if (IsAssociativeContainer (* GetCollectionProxy ()) ) {
5864
5876
fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesAssociativeCollectionMember;
5865
5877
} else {
5866
5878
fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionMember;
0 commit comments