Replace dynamic_casts with static_casts

dynamic_cast is not free. Replace obvious instances (where the result is
unconditionally dereferenced) with static_cast in contexts with
performance implications.
This commit is contained in:
Geza Lore
2022-09-02 12:08:34 +01:00
parent 5c828b7e60
commit 2ba39b25f1
3 changed files with 17 additions and 17 deletions
+3 -3
View File
@@ -52,14 +52,14 @@ public:
~VarTspSorter() override = default;
// METHODS
virtual bool operator<(const TspStateBase& other) const override {
return operator<(dynamic_cast<const VarTspSorter&>(other));
return operator<(static_cast<const VarTspSorter&>(other));
}
bool operator<(const VarTspSorter& other) const { return m_serial < other.m_serial; }
const MTaskIdSet& mtaskIds() const { return m_mtaskIds; }
virtual int cost(const TspStateBase* otherp) const override {
return cost(dynamic_cast<const VarTspSorter*>(otherp));
return cost(static_cast<const VarTspSorter*>(otherp));
}
virtual int cost(const VarTspSorter* otherp) const {
int cost(const VarTspSorter* otherp) const {
int cost = diffs(m_mtaskIds, otherp->m_mtaskIds);
cost += diffs(otherp->m_mtaskIds, m_mtaskIds);
return cost;