Skip to content
Closed
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
35 changes: 6 additions & 29 deletions core/cont/src/TClonesArray.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -990,34 +990,7 @@ void TClonesArray::AbsorbObjects(TClonesArray *tc)

// tests
if (tc == 0 || tc == this || tc->GetEntriesFast() == 0) return;
if (fClass != tc->fClass) {
Error("AbsorbObjects", "cannot absorb objects when classes are different");
return;
}

// cache the sorted status
Bool_t wasSorted = IsSorted() && tc->IsSorted() &&
(Last() == 0 || Last()->Compare(tc->First()) == -1);

// expand this
Int_t oldSize = GetEntriesFast();
Int_t newSize = oldSize + tc->GetEntriesFast();
if(newSize > fSize)
Expand(newSize);

// move
for (Int_t i = 0; i < tc->GetEntriesFast(); ++i) {
fCont[oldSize+i] = tc->fCont[i];
(*fKeep)[oldSize+i] = (*(tc->fKeep))[i];
tc->fCont[i] = 0;
(*(tc->fKeep))[i] = 0;
}

// cleanup
fLast = newSize-1;
tc->fLast = -1;
if (!wasSorted)
Changed();
AbsorbObjects(tc, 0, tc->GetEntriesFast() - 1);
}

//______________________________________________________________________________
Expand All @@ -1026,7 +999,7 @@ void TClonesArray::AbsorbObjects(TClonesArray *tc, Int_t idx1, Int_t idx2)
// Directly move the range of object pointers from tc without cloning
// (copying).
// This TClonesArray takes over ownership of all of tc's object pointers
// from idx1 to idx2. The tc array is re-arranged by return.
// from idx1 to idx2 (inclusive). The tc array is re-arranged by return.

// tests
if (tc == 0 || tc == this || tc->GetEntriesFast() == 0) return;
Expand All @@ -1039,6 +1012,10 @@ void TClonesArray::AbsorbObjects(TClonesArray *tc, Int_t idx1, Int_t idx2)
Error("AbsorbObjects", "range is not valid: idx1>idx2");
return;
}
if (idx2 >= tc->GetEntriesFast()) {
Error("AbsorbObjects", "range is not valid: idx2 out of bounds");
return;
}

// cache the sorted status
Bool_t wasSorted = IsSorted() && tc->IsSorted() &&
Expand Down