Skip to content

[tree] Avoid redundant calls to GetInfoImp #18893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 36 additions & 31 deletions tree/tree/src/TBranchElement.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1053,9 +1053,10 @@ void TBranchElement::Browse(TBrowser* b)
// we can only find out asking the streamer given our ID
TStreamerElement *element=nullptr;
TClass* clsub=nullptr;
if (fID>=0 && GetInfoImp()
&& GetInfoImp()->IsCompiled()
&& ((element=GetInfoImp()->GetElement(fID)))
auto info = (fID >= 0) ? GetInfoImp() : nullptr;
if (info
&& info->IsCompiled()
&& ((element=info->GetElement(fID)))
&& ((clsub=element->GetClassPointer())))
cl=clsub;
}
Expand Down Expand Up @@ -3041,8 +3042,9 @@ T TBranchElement::GetTypedValue(Int_t j, Int_t len, bool subarr) const
return GetInfoImp()->GetTypedValueSTLP<T>(((TBranchElement*) this)->GetCollectionProxy(), prID, j/len, j%len, fOffset);
}
} else {
if (GetInfoImp()) {
return GetInfoImp()->GetTypedValue<T>(object, prID, j, -1);
auto info = GetInfoImp();
if (info) {
return info->GetTypedValue<T>(object, prID, j, -1);
}
return 0;
}
Expand All @@ -3056,10 +3058,12 @@ void* TBranchElement::GetValuePointer() const
{
ValidateAddress();

TStreamerInfo *info = nullptr;
Int_t prID = fID;
char *object = fObject;
if (TestBit(kCache)) {
if (GetInfoImp()->GetElements()->At(fID)->TestBit(TStreamerElement::kRepeat)) {
info = GetInfoImp();
if (info->GetElements()->At(fID)->TestBit(TStreamerElement::kRepeat)) {
prID = fID+1;
} else if (fOnfileObject) {
object = fOnfileObject->GetObjectAt(0);
Expand Down Expand Up @@ -3112,8 +3116,10 @@ void* TBranchElement::GetValuePointer() const
return object;
} else {
//return GetInfoImp()->GetValue(object,fID,j,-1);
if (!GetInfoImp() || !object) return nullptr;
char **val = (char**)(object+GetInfoImp()->TStreamerInfo::GetElementOffset(prID));
if (!info)
info = GetInfoImp();
if (!info || !object) return nullptr;
char **val = (char**)(object+info->TStreamerInfo::GetElementOffset(prID));
return *val;
}
}
Expand Down Expand Up @@ -3173,7 +3179,8 @@ void TBranchElement::InitializeOffsets()
return;
}
// Make sure we can instantiate our class streamer info.
if (!GetInfoImp()) {
TStreamerInfo *info = GetInfoImp();
if (!info) {
Warning("InitializeOffsets", "No streamer info available for branch: %s of class: %s", GetName(), fBranchClass.GetClass()->GetName());
fInitOffsets = true;
return;
Expand All @@ -3191,28 +3198,27 @@ void TBranchElement::InitializeOffsets()
if (fID > -1) {
// -- Branch is *not* a top-level branch.
// Instead of the streamer info class, we want the class of our
// specific element in the streamer info. We could be a data
// specific element in the streamer info. We could be a data
// member of a base class or a split class, in which case our
// streamer info will be for our containing sub-object, while
// we are actually a different type.
TVirtualStreamerInfo* si = GetInfoImp();
// Note: We tested to make sure the streamer info was available previously.
if (!si->IsCompiled()) {
if (!info->IsCompiled()) {
Warning("InitializeOffsets", "Streamer info for branch: %s has no elements array!", GetName());
fInitOffsets = true;
return;
}
// FIXME: Check that fID is in range.
branchElem = si->GetElement(fID);
branchElem = info->GetElement(fID);
if (!branchElem) {
Warning("InitializeOffsets", "Cannot get streamer element for branch: %s!", GetName());
fInitOffsets = true;
return;
} else if (branchElem->TestBit(TStreamerElement::kRepeat)) {
// If we have a repeating streamerElement, use the next
// one as it actually hold the 'real' data member('s offset)
if (si->GetElement(fID+1)) {
branchElem = si->GetElement(fID+1);
if (info->GetElement(fID+1)) {
branchElem = info->GetElement(fID+1);
}
}
localOffset = branchElem->GetOffset();
Expand Down Expand Up @@ -3863,12 +3869,12 @@ void TBranchElement::Print(Option_t* option) const
}
if (strncmp(option,"debugInfo",length("debugInfo"))==0) {
Printf("Branch %s uses:",GetName());
if (fID>=0) {
TStreamerInfo *localInfo = GetInfoImp();
if (fID>= 0) {
// GetInfoImp()->GetElement(fID)->ls();
// for(UInt_t i=0; i< fIDs.size(); ++i) {
// GetInfoImp()->GetElement(fIDs[i])->ls();
// }
TStreamerInfo *localInfo = GetInfoImp();
if (fType == 3 || fType == 4) {
// Search for the correct version.
localInfo = FindOnfileInfo(fClonesClass, fBranches);
Expand All @@ -3881,8 +3887,7 @@ void TBranchElement::Print(Option_t* option) const
if (fReadActionSequence) fReadActionSequence->Print(option);
Printf(" with write actions:");
if (fFillActionSequence) fFillActionSequence->Print(option);
} else if (!fNewIDs.empty() && GetInfoImp()) {
TStreamerInfo *localInfo = GetInfoImp();
} else if (!fNewIDs.empty() && localInfo) {
if (fType == 3 || fType == 4) {
// Search for the correct version.
localInfo = FindOnfileInfo(fClonesClass, fBranches);
Expand Down Expand Up @@ -3970,8 +3975,8 @@ void TBranchElement::PrintValue(Int_t lenmax) const
TLeafElement* leaf = (TLeafElement*) fLeaves.UncheckedAt(0);
n = n * leaf->GetLenStatic();
}
if (GetInfoImp()) {
GetInfoImp()->PrintValue(GetName(), fAddress, atype, n, lenmax);
if (info) {
info->PrintValue(GetName(), fAddress, atype, n, lenmax);
}
return;
} else if (fType <= 2) {
Expand All @@ -3981,12 +3986,12 @@ void TBranchElement::PrintValue(Int_t lenmax) const
Int_t atype = fStreamerType - 20;
TBranchElement* counterElement = (TBranchElement*) fBranchCount;
Int_t n = (Int_t) counterElement->GetValue(0, 0);
if (GetInfoImp()) {
GetInfoImp()->PrintValue(GetName(), fAddress, atype, n, lenmax);
if (info) {
info->PrintValue(GetName(), fAddress, atype, n, lenmax);
}
} else {
if (GetInfoImp()) {
GetInfoImp()->PrintValue(GetName(), object, prID, -1, lenmax);
if (info) {
info->PrintValue(GetName(), object, prID, -1, lenmax);
}
}
return;
Expand All @@ -3995,17 +4000,17 @@ void TBranchElement::PrintValue(Int_t lenmax) const
printf(" %-15s = %d\n", GetName(), fNdata);
} else if (fType == 31) {
TClonesArray* clones = (TClonesArray*) object;
if (GetInfoImp()) {
GetInfoImp()->PrintValueClones(GetName(), clones, prID, fOffset, lenmax);
if (info) {
info->PrintValueClones(GetName(), clones, prID, fOffset, lenmax);
}
} else if (fType == 41) {
TVirtualCollectionProxy::TPushPop helper(((TBranchElement*) this)->GetCollectionProxy(), object);
if (GetInfoImp()) {
GetInfoImp()->PrintValueSTL(GetName(), ((TBranchElement*) this)->GetCollectionProxy(), prID, fOffset, lenmax);
if (info) {
info->PrintValueSTL(GetName(), ((TBranchElement*) this)->GetCollectionProxy(), prID, fOffset, lenmax);
}
} else {
if (GetInfoImp()) {
GetInfoImp()->PrintValue(GetName(), object, prID, -1, lenmax);
if (info) {
info->PrintValue(GetName(), object, prID, -1, lenmax);
}
}
}
Expand Down
Loading