Skip to content

Commit

Permalink
use constexpr if
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou committed May 21, 2024
1 parent 5d2cd4d commit edc4522
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions include/engine/routing_algorithms/routing_base_mld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,18 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const auto &cell =
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
auto destination = cell.GetDestinationNodes().begin();
auto distance = [&heapNode]() -> auto {
auto distance = [&heapNode, &cell]() -> auto {
if constexpr (std::is_same_v<typename SearchEngineData<
mld::Algorithm>::MapMatchingQueryHeap,
Heap>) {

return cell.GetOutDistance(heapNode.node).begin();
} else {
(void)cell;
(void)heapNode;
return 0;
}
} ;
}();
for (auto shortcut_weight : cell.GetOutWeight(heapNode.node))
{
BOOST_ASSERT(destination != cell.GetDestinationNodes().end());
Expand All @@ -313,7 +315,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
if (!toHeapNode)
{
if constexpr (std::is_same_v<typename SearchEngineData<
Algorithm>::MapMatchingQueryHeap,
mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
const EdgeDistance to_distance = heapNode.data.distance + *distance;
Expand All @@ -327,7 +329,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
else if (to_weight < toHeapNode->weight)
{
if constexpr (std::is_same_v<typename SearchEngineData<
Algorithm>::MapMatchingQueryHeap,
mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
const EdgeDistance to_distance = heapNode.data.distance + *distance;
Expand All @@ -351,16 +353,18 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const auto &cell =
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
auto source = cell.GetSourceNodes().begin();
auto distance = [&heapNode]() -> auto {
auto distance = [&heapNode, &cell]() -> auto {
if constexpr (std::is_same_v<typename SearchEngineData<
mld::Algorithm>::MapMatchingQueryHeap,
Heap>) {

return cell.GetOutDistance(heapNode.node).begin();
} else {
(void)cell;
(void)heapNode;
return 0;
}
} ;
}();
for (auto shortcut_weight : cell.GetInWeight(heapNode.node))
{
BOOST_ASSERT(source != cell.GetSourceNodes().end());
Expand All @@ -374,7 +378,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
if (!toHeapNode)
{
if constexpr (std::is_same_v<typename SearchEngineData<
Algorithm>::MapMatchingQueryHeap,
mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
const EdgeDistance to_distance = heapNode.data.distance + *distance;
Expand All @@ -388,7 +392,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
else if (to_weight < toHeapNode->weight)
{
if constexpr (std::is_same_v<typename SearchEngineData<
Algorithm>::MapMatchingQueryHeap,
mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
const EdgeDistance to_distance = heapNode.data.distance + *distance;
Expand Down Expand Up @@ -434,7 +438,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
if (!toHeapNode)
{
if constexpr (std::is_same_v<
typename SearchEngineData<Algorithm>::MapMatchingQueryHeap,
typename SearchEngineData<mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
const auto node_distance =
Expand All @@ -452,7 +456,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
else if (to_weight < toHeapNode->weight)
{
if constexpr (std::is_same_v<
typename SearchEngineData<Algorithm>::MapMatchingQueryHeap,
typename SearchEngineData<mld::Algorithm>::MapMatchingQueryHeap,
Heap>)
{
const auto node_distance =
Expand Down

0 comments on commit edc4522

Please sign in to comment.