Skip to content

Commit 88d9b7b

Browse files
Change members from value to unique_ptr
This change will save memory because the underlying vectors of events that aren't used will be nullptr rather than vector of default capacity.
1 parent 9a2601e commit 88d9b7b

File tree

4 files changed

+516
-377
lines changed

4 files changed

+516
-377
lines changed

Framework/DataObjects/inc/MantidDataObjects/EventList.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ class MANTID_DATAOBJECTS_DLL EventList : public Mantid::API::IEventList {
102102
* @param event :: TofEvent to add at the end of the list.
103103
* */
104104
inline void addEventQuickly(const Types::Event::TofEvent &event) {
105-
this->events.emplace_back(event);
106-
this->setSortOrder(UNSORTED);
105+
this->events->emplace_back(event);
106+
if (this->order != UNSORTED)
107+
this->setSortOrder(UNSORTED);
107108
}
108109

109110
// --------------------------------------------------------------------------
@@ -112,8 +113,9 @@ class MANTID_DATAOBJECTS_DLL EventList : public Mantid::API::IEventList {
112113
* @param event :: WeightedEvent to add at the end of the list.
113114
* */
114115
inline void addEventQuickly(const WeightedEvent &event) {
115-
this->weightedEvents.emplace_back(event);
116-
this->setSortOrder(UNSORTED);
116+
this->weightedEvents->emplace_back(event);
117+
if (this->order != UNSORTED)
118+
this->setSortOrder(UNSORTED);
117119
}
118120

119121
// --------------------------------------------------------------------------
@@ -122,8 +124,9 @@ class MANTID_DATAOBJECTS_DLL EventList : public Mantid::API::IEventList {
122124
* @param event :: WeightedEventNoTime to add at the end of the list.
123125
* */
124126
inline void addEventQuickly(const WeightedEventNoTime &event) {
125-
this->weightedEventsNoTime.emplace_back(event);
126-
this->setSortOrder(UNSORTED);
127+
this->weightedEventsNoTime->emplace_back(event);
128+
if (this->order != UNSORTED)
129+
this->setSortOrder(UNSORTED);
127130
}
128131

129132
Mantid::API::EventType getEventType() const override;
@@ -326,13 +329,13 @@ class MANTID_DATAOBJECTS_DLL EventList : public Mantid::API::IEventList {
326329
HistogramData::Histogram m_histogram;
327330

328331
/// List of TofEvent (no weights).
329-
mutable std::vector<Types::Event::TofEvent> events;
332+
mutable std::unique_ptr<std::vector<Types::Event::TofEvent>> events;
330333

331334
/// List of WeightedEvent's
332-
mutable std::vector<WeightedEvent> weightedEvents;
335+
mutable std::unique_ptr<std::vector<WeightedEvent>> weightedEvents;
333336

334337
/// List of WeightedEvent's
335-
mutable std::vector<WeightedEventNoTime> weightedEventsNoTime;
338+
mutable std::unique_ptr<std::vector<WeightedEventNoTime>> weightedEventsNoTime;
336339

337340
/// What type of event is in our list.
338341
Mantid::API::EventType eventType;

0 commit comments

Comments
 (0)