From 71bf1edc5ead5c60e74c6b17d4a0d2477b873698 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Wed, 30 Sep 2015 16:29:19 +0200 Subject: [PATCH] Run Modernizer --- data_structures/raster_source.cpp | 4 ++-- datastore.cpp | 4 ++-- plugins/trip.hpp | 23 +++++++++++------------ util/matching_debug_info.hpp | 6 +++--- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/data_structures/raster_source.cpp b/data_structures/raster_source.cpp index f935b9d87..9e880a218 100644 --- a/data_structures/raster_source.cpp +++ b/data_structures/raster_source.cpp @@ -42,8 +42,8 @@ RasterSource::RasterSource(RasterGrid _raster_data, int _ymin, int _ymax) : xstep(calcSize(_xmin, _xmax, _width)), ystep(calcSize(_ymin, _ymax, _height)), - raster_data(_raster_data), width(_width), height(_height), xmin(_xmin), xmax(_xmax), - ymin(_ymin), ymax(_ymax) + raster_data(std::move(_raster_data)), width(_width), height(_height), xmin(_xmin), + xmax(_xmax), ymin(_ymin), ymax(_ymax) { BOOST_ASSERT(xstep != 0); BOOST_ASSERT(ystep != 0); diff --git a/datastore.cpp b/datastore.cpp index 3eee65ee3..754901ca4 100644 --- a/datastore.cpp +++ b/datastore.cpp @@ -219,8 +219,8 @@ int main(const int argc, const char *argv[]) try }(); // Allocate a memory layout in shared memory, deallocate previous - SharedMemory *layout_memory = SharedMemoryFactory::Get(layout_region, sizeof(SharedDataLayout)); - SharedDataLayout *shared_layout_ptr = new (layout_memory->Ptr()) SharedDataLayout(); + auto *layout_memory = SharedMemoryFactory::Get(layout_region, sizeof(SharedDataLayout)); + auto *shared_layout_ptr = new (layout_memory->Ptr()) SharedDataLayout(); shared_layout_ptr->SetBlockSize(SharedDataLayout::FILE_INDEX_PATH, file_index_path.length() + 1); diff --git a/plugins/trip.hpp b/plugins/trip.hpp index ad5ff99b8..57631a6ac 100644 --- a/plugins/trip.hpp +++ b/plugins/trip.hpp @@ -119,25 +119,25 @@ template class RoundTripPlugin final : public BasePlugin // => in_component = [0, 1, 2, 4, 5, 3, 6, 7, 8] // => in_range = [0, 5] SCC_Component(std::vector in_component, std::vector in_range) - : component(in_component), range(in_range) + : component(std::move(in_component)), range(std::move(in_range)) { - range.push_back(in_component.size()); + range.push_back(component.size()); - BOOST_ASSERT_MSG(in_component.size() >= in_range.size(), + BOOST_ASSERT_MSG(component.size() >= range.size(), "scc component and its ranges do not match"); - BOOST_ASSERT_MSG(in_component.size() > 0, "there's no scc component"); - BOOST_ASSERT_MSG(*std::max_element(in_range.begin(), in_range.end()) <= - in_component.size(), + BOOST_ASSERT_MSG(component.size() > 0, "there's no scc component"); + BOOST_ASSERT_MSG(*std::max_element(range.begin(), range.end()) <= + component.size(), "scc component ranges are out of bound"); - BOOST_ASSERT_MSG(*std::min_element(in_range.begin(), in_range.end()) >= 0, + BOOST_ASSERT_MSG(*std::min_element(range.begin(), range.end()) >= 0, "invalid scc component range"); - BOOST_ASSERT_MSG(std::is_sorted(std::begin(in_range), std::end(in_range)), + BOOST_ASSERT_MSG(std::is_sorted(std::begin(range), std::end(range)), "invalid component ranges"); }; // constructor to use when whole graph is one single scc SCC_Component(std::vector in_component) - : component(in_component), range({0, in_component.size()}){}; + : component(std::move(in_component)), range({0, component.size()}){}; std::size_t GetNumberOfComponents() const { @@ -322,10 +322,9 @@ template class RoundTripPlugin final : public BasePlugin // compute all round trip routes std::vector comp_route; comp_route.reserve(route_result.size()); - for (std::size_t r = 0; r < route_result.size(); ++r) + for (auto &elem : route_result) { - comp_route.push_back( - ComputeRoute(phantom_node_vector, route_parameters, route_result[r])); + comp_route.push_back(ComputeRoute(phantom_node_vector, route_parameters, elem)); } TIMER_STOP(TRIP_TIMER); diff --git a/util/matching_debug_info.hpp b/util/matching_debug_info.hpp index 850bcd2b0..aad47b209 100644 --- a/util/matching_debug_info.hpp +++ b/util/matching_debug_info.hpp @@ -57,13 +57,13 @@ struct MatchingDebugInfo for (auto &elem : candidates_list) { osrm::json::Array timestamps; - for (unsigned s = 0; s < elem.size(); s++) + for (auto &elem_s : elem) { osrm::json::Object state; state.values["transitions"] = osrm::json::Array(); state.values["coordinate"] = - osrm::json::make_array(elem[s].first.location.lat / COORDINATE_PRECISION, - elem[s].first.location.lon / COORDINATE_PRECISION); + osrm::json::make_array(elem_s.first.location.lat / COORDINATE_PRECISION, + elem_s.first.location.lon / COORDINATE_PRECISION); state.values["viterbi"] = osrm::json::clamp_float(osrm::matching::IMPOSSIBLE_LOG_PROB); state.values["pruned"] = 0u;