Unverified Commit 1a39f6b2 authored by Nick Draper's avatar Nick Draper Committed by GitHub
Browse files

Merge pull request #28398 from mantidproject/eventlist_reserve

Eventlist: reserve capacity of the specified event type
parents cb38adb0 86e40d9f
......@@ -932,16 +932,26 @@ void EventList::clearData() { this->clear(false); }
*/
void EventList::setMRU(EventWorkspaceMRU *newMRU) { mru = newMRU; }
/** Reserve a certain number of entries in the (NOT-WEIGHTED) event list. Do NOT
*call
* on weighted events!
/** Reserve a certain number of entries in event list of the specified eventType
*
* Calls std::vector<>::reserve() in order to pre-allocate the length of the
*event list vector.
*
* @param num :: number of events that will be in this EventList
*/
void EventList::reserve(size_t num) { this->events.reserve(num); }
void EventList::reserve(size_t num) {
switch (this->eventType) {
case TOF:
this->events.reserve(num);
break;
case WEIGHTED:
this->weightedEvents.reserve(num);
break;
case WEIGHTED_NOTIME:
this->weightedEventsNoTime.reserve(num);
break;
}
}
// ==============================================================================================
// --- Sorting functions -----------------------------------------------------
......
......@@ -151,14 +151,10 @@ inline DateAndTime::DateAndTime() : _nanoseconds(0) {}
/** Construct a date from nanoseconds.
* @param total_nanoseconds :: nanoseconds since Jan 1, 1990 (our epoch).
*/
inline DateAndTime::DateAndTime(const int64_t total_nanoseconds) {
inline DateAndTime::DateAndTime(const int64_t total_nanoseconds)
: _nanoseconds{
std::clamp(total_nanoseconds, MIN_NANOSECONDS, MAX_NANOSECONDS)} {
// Make sure that you cannot construct a date that is beyond the limits...
if (total_nanoseconds > MAX_NANOSECONDS)
_nanoseconds = MAX_NANOSECONDS;
else if (total_nanoseconds < MIN_NANOSECONDS)
_nanoseconds = MIN_NANOSECONDS;
else
_nanoseconds = total_nanoseconds;
}
/** + operator to add time.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment