CSplinePathExtra: Collapse RemoveWaypoint loop into find_if()

This commit is contained in:
Lioncash 2020-06-20 00:00:09 -04:00
parent 487f2ae176
commit 8c06309364
2 changed files with 9 additions and 10 deletions

View File

@ -64,16 +64,15 @@ void CSplinePathExtra::AddWaypoints()
}
}
void CSplinePathExtra::RemoveWaypoint(CWaypointExtra *pWaypoint)
void CSplinePathExtra::RemoveWaypoint(const CWaypointExtra *pWaypoint)
{
for (auto it = mWaypoints.begin(); it != mWaypoints.end(); ++it)
{
if (*it == pWaypoint)
{
mWaypoints.erase(it);
break;
}
}
const auto iter = std::find_if(mWaypoints.cbegin(), mWaypoints.cend(),
[pWaypoint](const auto* entry) { return entry == pWaypoint; });
if (iter == mWaypoints.cend())
return;
mWaypoints.erase(iter);
}
void CSplinePathExtra::ClearWaypoints()

View File

@ -24,7 +24,7 @@ public:
void FindAttachedWaypoints(std::set<CWaypointExtra*>& rChecked, CWaypointExtra* pWaypoint);
void AddWaypoints();
void RemoveWaypoint(CWaypointExtra* pWaypoint);
void RemoveWaypoint(const CWaypointExtra* pWaypoint);
void ClearWaypoints();
};