Skip to content

Commit 3208bad

Browse files
committed
[tree] Small cleanups in TEventList.
- Remove unused headers. - Use member initialisers to clean up constructors. - Apply clang-tidy/clang-format fixes for member init.
1 parent 85cdc29 commit 3208bad

2 files changed

Lines changed: 28 additions & 45 deletions

File tree

tree/tree/inc/TEventList.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ class TCollection;
3131
class TEventList : public TNamed {
3232

3333
protected:
34-
Int_t fN; ///< Number of elements in the list
35-
Int_t fSize; ///< Size of array
36-
Int_t fDelta; ///< Increment size
37-
bool fReapply; ///< If true, TTree::Draw will 'reapply' the original cut
38-
Long64_t *fList; ///<[fN]Array of elements
39-
TDirectory *fDirectory; ///<! Pointer to directory holding this tree
34+
Int_t fN = 0; ///< Number of elements in the list
35+
Int_t fSize = 100; ///< Size of array
36+
Int_t fDelta = 100; ///< Increment size
37+
bool fReapply = false; ///< If true, TTree::Draw will 'reapply' the original cut
38+
Long64_t *fList = nullptr; ///<[fN]Array of elements
39+
TDirectory *fDirectory = nullptr; ///<! Pointer to directory holding this tree
4040

4141
public:
42-
TEventList();
42+
TEventList() = default;
4343
TEventList(const char *name, const char *title="",Int_t initsize=0, Int_t delta = 0);
4444
TEventList(const TEventList &list);
4545
~TEventList() override;

tree/tree/src/TEventList.cxx

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -50,66 +50,49 @@ the TEventList object created in the above commands:
5050
#include "TBuffer.h"
5151
#include "TCut.h"
5252
#include "TDirectory.h"
53-
#include "TList.h"
54-
#include "TMath.h"
55-
#include "strlcpy.h"
56-
#include "snprintf.h"
53+
#include "TCollection.h"
54+
#include "TMathBase.h"
55+
#include "TROOT.h"
5756

58-
59-
////////////////////////////////////////////////////////////////////////////////
60-
/// Default constructor for a EventList.
61-
62-
TEventList::TEventList(): TNamed()
63-
{
64-
fN = 0;
65-
fSize = 100;
66-
fDelta = 100;
67-
fList = nullptr;
68-
fDirectory = nullptr;
69-
fReapply = false;
70-
}
57+
#include <algorithm>
7158

7259
////////////////////////////////////////////////////////////////////////////////
7360
/// Create a EventList.
7461
///
7562
/// This Eventlist is added to the list of objects in current directory.
7663

7764
TEventList::TEventList(const char *name, const char *title, Int_t initsize, Int_t delta)
78-
:TNamed(name,title), fReapply(false)
65+
: TNamed(name, title), fSize(std::max(100, initsize)), fDelta(std::max(100, delta))
7966
{
80-
fN = 0;
81-
if (initsize > 100) fSize = initsize;
82-
else fSize = 100;
83-
if (delta > 100) fDelta = delta;
84-
else fDelta = 100;
85-
fList = nullptr;
86-
fDirectory = gDirectory;
87-
if (fDirectory) fDirectory->Append(this);
67+
if (ROOT::Experimental::ObjectAutoRegistrationEnabled()) {
68+
fDirectory = gDirectory;
69+
if (fDirectory)
70+
fDirectory->Append(this);
71+
}
8872
}
8973

9074
////////////////////////////////////////////////////////////////////////////////
9175
/// Copy constructor.
9276

93-
TEventList::TEventList(const TEventList &list) : TNamed(list)
77+
TEventList::TEventList(const TEventList &list)
78+
: TNamed(list),
79+
fN(list.fN),
80+
fSize(list.fSize),
81+
fDelta(list.fDelta),
82+
fReapply(list.fReapply),
83+
fList(new Long64_t[fSize])
9484
{
95-
fN = list.fN;
96-
fSize = list.fSize;
97-
fDelta = list.fDelta;
98-
fList = new Long64_t[fSize];
99-
for (Int_t i=0; i<fN; i++)
100-
fList[i] = list.fList[i];
101-
fReapply = list.fReapply;
102-
fDirectory = nullptr;
85+
std::copy(list.fList, list.fList + list.fN, fList);
10386
}
10487

10588
////////////////////////////////////////////////////////////////////////////////
10689
/// Default destructor for a EventList.
10790

10891
TEventList::~TEventList()
10992
{
110-
delete [] fList; fList = nullptr;
111-
if (fDirectory) fDirectory->Remove(this);
112-
fDirectory = nullptr;
93+
delete[] fList;
94+
if (fDirectory)
95+
fDirectory->Remove(this);
11396
}
11497

11598
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)