From 59bceee258672c110fdd5d276c553022f99b23e9 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 16 Apr 2015 16:08:10 +0200 Subject: [PATCH] make sure GetNumberOfNodes() is only called once --- algorithms/tiny_components.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/algorithms/tiny_components.hpp b/algorithms/tiny_components.hpp index f3ca3c412..8eb61a912 100644 --- a/algorithms/tiny_components.hpp +++ b/algorithms/tiny_components.hpp @@ -95,18 +95,18 @@ template class TarjanSCC void run() { TIMER_START(SCC_RUN); + const NodeID max_node_id = m_node_based_graph->GetNumberOfNodes(); + // The following is a hack to distinguish between stuff that happens // before the recursive call and stuff that happens after std::stack recursion_stack; // true = stuff before, false = stuff after call std::stack tarjan_stack; - std::vector tarjan_node_list(m_node_based_graph->GetNumberOfNodes()); + std::vector tarjan_node_list(max_node_id); unsigned component_index = 0, size_of_current_component = 0; unsigned index = 0; - const NodeID last_node = m_node_based_graph->GetNumberOfNodes(); - std::vector processing_node_before_recursion(m_node_based_graph->GetNumberOfNodes(), - true); - for (const NodeID node : osrm::irange(0u, last_node)) + std::vector processing_node_before_recursion(max_node_id, true); + for (const NodeID node : osrm::irange(0u, max_node_id)) { if (SPECIAL_NODEID == components_index[node]) {