Skip to content
Snippets Groups Projects
Commit e2196f0e authored by Enrico Guiraud's avatar Enrico Guiraud Committed by Philippe Canal
Browse files

[TObjArray] Add GetEntriesUnsafe

GetEntriesFast is not as fast as it could be: it constructs and
destructs a TReadLockGuard, and might need to modify fLast.
GetEntriesUnsafe is a thread-unsafe version of GetEntriesFast
that side-steps these operations when possible.
parent 883b67a8
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,7 @@ public:
Int_t GetEntriesFast() const {
return GetAbsLast() + 1; //only OK when no gaps
}
Int_t GetEntriesUnsafe() const;
Int_t GetLast() const;
TObject **GetObjectRef() const { return fCont; };
TObject **GetObjectRef(const TObject *obj) const;
......
......@@ -554,6 +554,19 @@ Int_t TObjArray::GetAbsLast() const
return fLast;
}
////////////////////////////////////////////////////////////////////////////////
/// Return the number of objects in array (i.e. number of non-empty slots).
/// This is a thread-unsafe version of GetEntriesFast. Use it only if sure
/// it will not be invoked concurrently.
Int_t TObjArray::GetEntriesUnsafe() const
{
if (R__unlikely(fLast == -2))
return GetEntriesFast();
else
return fLast + 1;
}
////////////////////////////////////////////////////////////////////////////////
/// Return index of last object in array. Returns lowerBound-1 in case
/// array is empty.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment