refactor(Core): apply clang-tidy modernize-use-nodiscard (#3835)

This commit is contained in:
Francesco Borzì
2020-12-06 19:39:48 +01:00
committed by GitHub
parent d4a58700d4
commit 161302252e
82 changed files with 1565 additions and 1569 deletions

View File

@@ -29,7 +29,7 @@ public:
// e_time is execution time, p_time is update interval
virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; }
virtual bool IsDeletable() const { return true; } // this event can be safely deleted
[[nodiscard]] virtual bool IsDeletable() const { return true; } // this event can be safely deleted
virtual void Abort(uint64 /*e_time*/) { } // this method executes when the event is aborted
@@ -52,10 +52,10 @@ public:
void Update(uint32 p_time);
void KillAllEvents(bool force);
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
uint64 CalculateTime(uint64 t_offset) const;
[[nodiscard]] uint64 CalculateTime(uint64 t_offset) const;
// Xinef: calculates next queue tick time
uint64 CalculateQueueTime(uint64 delay) const;
[[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const;
protected:
uint64 m_time;

View File

@@ -85,12 +85,12 @@ public:
_interval = interval;
}
time_t GetInterval() const
[[nodiscard]] time_t GetInterval() const
{
return _interval;
}
time_t GetCurrent() const
[[nodiscard]] time_t GetCurrent() const
{
return _current;
}
@@ -115,7 +115,7 @@ public:
i_expiryTime -= diff;
}
bool Passed() const
[[nodiscard]] bool Passed() const
{
return i_expiryTime <= 0;
}
@@ -125,7 +125,7 @@ public:
i_expiryTime = interval;
}
time_t GetExpiry() const
[[nodiscard]] time_t GetExpiry() const
{
return i_expiryTime;
}
@@ -149,7 +149,7 @@ public:
i_expiryTime -= diff;
}
bool Passed() const
[[nodiscard]] bool Passed() const
{
return i_expiryTime <= 0;
}
@@ -159,7 +159,7 @@ public:
i_expiryTime = interval;
}
int32 GetExpiry() const
[[nodiscard]] int32 GetExpiry() const
{
return i_expiryTime;
}
@@ -195,7 +195,7 @@ public:
// Tracker interface
void TUpdate(int32 diff) { i_expireTime -= diff; }
bool TPassed() const { return i_expireTime <= 0; }
[[nodiscard]] bool TPassed() const { return i_expireTime <= 0; }
void TReset(int32 diff, int32 period) { i_expireTime += period > diff ? period : diff; }
private:

View File

@@ -43,10 +43,10 @@ public:
Tokenizer(const std::string& src, char const sep, uint32 vectorReserve = 0);
~Tokenizer() { delete[] m_str; }
const_iterator begin() const { return m_storage.begin(); }
const_iterator end() const { return m_storage.end(); }
[[nodiscard]] const_iterator begin() const { return m_storage.begin(); }
[[nodiscard]] const_iterator end() const { return m_storage.end(); }
size_type size() const { return m_storage.size(); }
[[nodiscard]] size_type size() const { return m_storage.size(); }
reference operator [] (size_type i) { return m_storage[i]; }
const_reference operator [] (size_type i) const { return m_storage[i]; }
@@ -404,12 +404,12 @@ public:
part[2] = p3;
}
inline bool IsEqual(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0) const
[[nodiscard]] inline bool IsEqual(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0) const
{
return (part[0] == p1 && part[1] == p2 && part[2] == p3);
}
inline bool HasFlag(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0) const
[[nodiscard]] inline bool HasFlag(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0) const
{
return (part[0] & p1 || part[1] & p2 || part[2] & p3);
}
@@ -605,7 +605,7 @@ public:
* @name GetTimer
* @return Current timer value.
*/
uint32 GetTimer() const
[[nodiscard]] uint32 GetTimer() const
{
return _time;
}
@@ -619,7 +619,7 @@ public:
* @name GetPhaseMask
* @return Active phases as mask.
*/
uint8 GetPhaseMask() const
[[nodiscard]] uint8 GetPhaseMask() const
{
return _phase;
}
@@ -628,7 +628,7 @@ public:
* @name Empty
* @return True, if there are no events scheduled.
*/
bool Empty() const
[[nodiscard]] bool Empty() const
{
return _eventMap.empty();
}
@@ -869,7 +869,7 @@ public:
* @param eventId Wanted event id.
* @return Time of found event.
*/
uint32 GetNextEventTime(uint32 eventId) const
[[nodiscard]] uint32 GetNextEventTime(uint32 eventId) const
{
if (Empty())
{
@@ -891,7 +891,7 @@ public:
* @name GetNextEventTime
* @return Time of next event.
*/
uint32 GetNextEventTime() const
[[nodiscard]] uint32 GetNextEventTime() const
{
return Empty() ? 0 : _eventMap.begin()->first;
}