Skip to content

Commit ecf7287

Browse files
committed
tree: factor out the check for associative container.
Fix one case that had not been updated to support multimap/multiset.
1 parent 8a14708 commit ecf7287

File tree

1 file changed

+40
-56
lines changed

1 file changed

+40
-56
lines changed

tree/tree/src/TBranchElement.cxx

Lines changed: 40 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ namespace {
7878
if (fOnfileObject) fBuffer.PopDataCache();
7979
}
8080
};
81+
bool IsAssociativeContainer(Int_t stltype) {
82+
switch (stltype) {
83+
case ROOT::kSTLset:
84+
case ROOT::kSTLmultiset:
85+
case ROOT::kSTLunorderedset:
86+
case ROOT::kSTLunorderedmultiset:
87+
case ROOT::kSTLmap:
88+
case ROOT::kSTLmultimap:
89+
case ROOT::kSTLunorderedmap:
90+
case ROOT::kSTLunorderedmultimap:
91+
return true;
92+
default:
93+
return false;
94+
}
95+
}
8196
}
8297

8398
////////////////////////////////////////////////////////////////////////////////
@@ -2711,27 +2726,16 @@ Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall)
27112726
}
27122727
nbytes += nb;
27132728
}
2714-
switch(fSTLtype) {
2715-
case ROOT::kSTLset:
2716-
case ROOT::kSTLmultiset:
2717-
case ROOT::kSTLunorderedset:
2718-
case ROOT::kSTLunorderedmultiset:
2719-
case ROOT::kSTLmap:
2720-
case ROOT::kSTLmultimap:
2721-
case ROOT::kSTLunorderedmap:
2722-
case ROOT::kSTLunorderedmultimap:
2723-
break;
2724-
default:
2725-
ValidateAddress(); // There is no ReadLeave for this node, so we need to do the validation here.
2726-
for (Int_t i = 0; i < nbranches; ++i) {
2727-
TBranch* branch = (TBranch*) fBranches.UncheckedAt(i);
2728-
Int_t nb = branch->GetEntry(entry, getall);
2729-
if (nb < 0) {
2730-
return nb;
2731-
}
2732-
nbytes += nb;
2729+
if (!IsAssociativeContainer(fSTLtype)) {
2730+
ValidateAddress(); // There is no ReadLeave for this node, so we need to do the validation here.
2731+
for (Int_t i = 0; i < nbranches; ++i) {
2732+
TBranch* branch = (TBranch*) fBranches.UncheckedAt(i);
2733+
Int_t nb = branch->GetEntry(entry, getall);
2734+
if (nb < 0) {
2735+
return nb;
27332736
}
2734-
break;
2737+
nbytes += nb;
2738+
}
27352739
}
27362740
if (!TestBit(kDecomposedObj) && fReadActionSequence && !fReadActionSequence->fActions.empty()) {
27372741
if (fType == 3) {
@@ -4060,23 +4064,14 @@ void TBranchElement::ReadLeavesMakeClass(TBuffer& b)
40604064
}
40614065
}
40624066
fNdata = n[0];
4063-
if (fType == 4) {
4067+
if (fType == 4 && IsAssociativeContainer(fSTLtype)) {
40644068
Int_t nbranches = fBranches.GetEntriesFast();
4065-
switch(fSTLtype) {
4066-
case ROOT::kSTLset:
4067-
case ROOT::kSTLmultiset:
4068-
case ROOT::kSTLmap:
4069-
case ROOT::kSTLmultimap:
4070-
for (Int_t i=0; i<nbranches; i++) {
4071-
TBranch *branch = (TBranch*)fBranches[i];
4072-
Int_t nb = branch->GetEntry(GetReadEntry(), 1);
4073-
if (nb < 0) {
4074-
break;
4075-
}
4076-
}
4077-
break;
4078-
default:
4069+
for (Int_t i=0; i<nbranches; i++) {
4070+
TBranch *branch = (TBranch*)fBranches[i];
4071+
Int_t nb = branch->GetEntry(GetReadEntry(), 1);
4072+
if (nb < 0) {
40794073
break;
4074+
}
40804075
}
40814076
}
40824077
return;
@@ -4328,28 +4323,17 @@ void TBranchElement::ReadLeavesCollection(TBuffer& b)
43284323
fIterators->CreateIterators(alternate, proxy);
43294324
}
43304325

4331-
Int_t nbranches = fBranches.GetEntriesFast();
4332-
switch (fSTLtype) {
4333-
case ROOT::kSTLset:
4334-
case ROOT::kSTLunorderedset:
4335-
case ROOT::kSTLunorderedmultiset:
4336-
case ROOT::kSTLmultiset:
4337-
case ROOT::kSTLmap:
4338-
case ROOT::kSTLmultimap:
4339-
case ROOT::kSTLunorderedmap:
4340-
case ROOT::kSTLunorderedmultimap:
4341-
for (Int_t i = 0; i < nbranches; ++i) {
4342-
TBranch *branch = (TBranch*) fBranches[i];
4343-
Int_t nb = branch->GetEntry(GetReadEntry(), 1);
4344-
if (nb < 0) {
4345-
// Give up on i/o failure.
4346-
// FIXME: We need an error message here.
4347-
break;
4348-
}
4326+
if (IsAssociativeContainer(fSTLtype)) {
4327+
Int_t nbranches = fBranches.GetEntriesFast();
4328+
for (Int_t i = 0; i < nbranches; ++i) {
4329+
TBranch *branch = (TBranch*) fBranches[i];
4330+
Int_t nb = branch->GetEntry(GetReadEntry(), 1);
4331+
if (nb < 0) {
4332+
// Give up on i/o failure.
4333+
// FIXME: We need an error message here.
4334+
break;
43494335
}
4350-
break;
4351-
default:
4352-
break;
4336+
}
43534337
}
43544338
//------------------------------------------------------------------------
43554339
// We have split this stuff, so we need to create the pointers

0 commit comments

Comments
 (0)