Use early exit/continue to simplify code and reduce indentation
This commit is contained in:
parent
c881aa7b32
commit
cfa83658dc
@ -145,23 +145,25 @@ bool RestrictionMap::CheckIfTurnIsRestricted(const NodeID node_u,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto restriction_iter = m_restriction_map.find({node_u, node_v});
|
const auto restriction_iter = m_restriction_map.find({node_u, node_v});
|
||||||
if (restriction_iter != m_restriction_map.end())
|
if (restriction_iter == m_restriction_map.end())
|
||||||
{
|
{
|
||||||
const unsigned index = restriction_iter->second;
|
return false;
|
||||||
const auto &bucket = m_restriction_bucket_list.at(index);
|
}
|
||||||
|
|
||||||
for (const RestrictionTarget &restriction_target : bucket)
|
const unsigned index = restriction_iter->second;
|
||||||
|
const auto &bucket = m_restriction_bucket_list.at(index);
|
||||||
|
|
||||||
|
for (const RestrictionTarget &restriction_target : bucket)
|
||||||
|
{
|
||||||
|
if (node_w == restriction_target.target_node && // target found
|
||||||
|
!restriction_target.is_only) // and not an only_-restr.
|
||||||
{
|
{
|
||||||
if (node_w == restriction_target.target_node && // target found
|
return true;
|
||||||
!restriction_target.is_only) // and not an only_-restr.
|
}
|
||||||
{
|
if (node_w != restriction_target.target_node && // target not found
|
||||||
return true;
|
restriction_target.is_only) // and is an only restriction
|
||||||
}
|
{
|
||||||
if (node_w != restriction_target.target_node && // target not found
|
return true;
|
||||||
restriction_target.is_only) // and is an only restriction
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user