diff --git a/algorithms/bayes_classifier.hpp b/algorithms/bayes_classifier.hpp index 3358144c750..ea300c1a999 100644 --- a/algorithms/bayes_classifier.hpp +++ b/algorithms/bayes_classifier.hpp @@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include struct NormalDistribution { @@ -80,11 +81,11 @@ class BayesClassifier }; using ClassificationT = std::pair; - BayesClassifier(const PositiveDistributionT &positive_distribution, - const NegativeDistributionT &negative_distribution, + BayesClassifier(PositiveDistributionT positive_distribution, + NegativeDistributionT negative_distribution, const double positive_apriori_probability) - : positive_distribution(positive_distribution), - negative_distribution(negative_distribution), + : positive_distribution(std::move(positive_distribution)), + negative_distribution(std::move(negative_distribution)), positive_apriori_probability(positive_apriori_probability), negative_apriori_probability(1. - positive_apriori_probability) { diff --git a/algorithms/douglas_peucker.cpp b/algorithms/douglas_peucker.cpp index fa7d7826b85..280c90fa876 100644 --- a/algorithms/douglas_peucker.cpp +++ b/algorithms/douglas_peucker.cpp @@ -99,8 +99,8 @@ void DouglasPeucker::Run(RandomAccessIt begin, RandomAccessIt end, const unsigne { BOOST_ASSERT_MSG(zoom_level < DOUGLAS_PEUCKER_THRESHOLDS.size(), "unsupported zoom level"); - RandomAccessIt left_border = begin; - RandomAccessIt right_border = std::next(begin); + auto left_border = begin; + auto right_border = std::next(begin); // Sweep over array and identify those ranges that need to be checked do { diff --git a/algorithms/graph_compressor.cpp b/algorithms/graph_compressor.cpp index d375a588bde..f3b5f8dd957 100644 --- a/algorithms/graph_compressor.cpp +++ b/algorithms/graph_compressor.cpp @@ -8,8 +8,8 @@ #include "../util/simple_logger.hpp" -GraphCompressor::GraphCompressor(const SpeedProfileProperties& speed_profile) - : speed_profile(speed_profile) +GraphCompressor::GraphCompressor(SpeedProfileProperties speed_profile) + : speed_profile(std::move(speed_profile)) { } diff --git a/algorithms/graph_compressor.hpp b/algorithms/graph_compressor.hpp index c1cca153e6c..75405c0c940 100644 --- a/algorithms/graph_compressor.hpp +++ b/algorithms/graph_compressor.hpp @@ -43,7 +43,7 @@ class GraphCompressor using EdgeData = NodeBasedDynamicGraph::EdgeData; public: - GraphCompressor(const SpeedProfileProperties& speed_profile); + GraphCompressor(SpeedProfileProperties speed_profile); void Compress(const std::unordered_set& barrier_nodes, const std::unordered_set& traffic_lights, diff --git a/contractor/edge_based_graph_factory.cpp b/contractor/edge_based_graph_factory.cpp index 93a07a37665..b2ca9778fd2 100644 --- a/contractor/edge_based_graph_factory.cpp +++ b/contractor/edge_based_graph_factory.cpp @@ -39,20 +39,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -EdgeBasedGraphFactory::EdgeBasedGraphFactory(std::shared_ptr node_based_graph, - const CompressedEdgeContainer& compressed_edge_container, - const std::unordered_set& barrier_nodes, - const std::unordered_set& traffic_lights, - std::shared_ptr restriction_map, - const std::vector &node_info_list, - const SpeedProfileProperties &speed_profile) - : m_node_info_list(node_info_list), - m_node_based_graph(node_based_graph), - m_restriction_map(restriction_map), - m_barrier_nodes(barrier_nodes), - m_traffic_lights(traffic_lights), - m_compressed_edge_container(compressed_edge_container), - speed_profile(speed_profile) +EdgeBasedGraphFactory::EdgeBasedGraphFactory( + std::shared_ptr node_based_graph, + const CompressedEdgeContainer &compressed_edge_container, + const std::unordered_set &barrier_nodes, + const std::unordered_set &traffic_lights, + std::shared_ptr restriction_map, + const std::vector &node_info_list, + SpeedProfileProperties speed_profile) + : m_node_info_list(node_info_list), m_node_based_graph(std::move(node_based_graph)), + m_restriction_map(std::move(restriction_map)), m_barrier_nodes(barrier_nodes), + m_traffic_lights(traffic_lights), m_compressed_edge_container(compressed_edge_container), + speed_profile(std::move(speed_profile)) { } diff --git a/contractor/edge_based_graph_factory.hpp b/contractor/edge_based_graph_factory.hpp index ceb6a88c135..a9ef8ea4dfa 100644 --- a/contractor/edge_based_graph_factory.hpp +++ b/contractor/edge_based_graph_factory.hpp @@ -58,14 +58,13 @@ class EdgeBasedGraphFactory EdgeBasedGraphFactory() = delete; EdgeBasedGraphFactory(const EdgeBasedGraphFactory &) = delete; - explicit EdgeBasedGraphFactory(std::shared_ptr node_based_graph, - const CompressedEdgeContainer& compressed_edge_container, - const std::unordered_set& barrier_nodes, - const std::unordered_set& traffic_lights, + const CompressedEdgeContainer &compressed_edge_container, + const std::unordered_set &barrier_nodes, + const std::unordered_set &traffic_lights, std::shared_ptr restriction_map, const std::vector &node_info_list, - const SpeedProfileProperties &speed_profile); + SpeedProfileProperties speed_profile); void Run(const std::string &original_edge_data_filename, lua_State *lua_state); diff --git a/contractor/processing_chain.hpp b/contractor/processing_chain.hpp index 09093bf0dde..33dbe917d8a 100644 --- a/contractor/processing_chain.hpp +++ b/contractor/processing_chain.hpp @@ -51,8 +51,7 @@ class Prepare using InputEdge = DynamicGraph::InputEdge; using StaticEdge = StaticGraph::InputEdge; - explicit Prepare(const ContractorConfig& contractor_config) - : config(contractor_config) {} + explicit Prepare(ContractorConfig contractor_config) : config(std::move(contractor_config)) {} Prepare(const Prepare &) = delete; ~Prepare(); diff --git a/data_structures/binary_heap.hpp b/data_structures/binary_heap.hpp index b237486aa7a..85703f4a6b5 100644 --- a/data_structures/binary_heap.hpp +++ b/data_structures/binary_heap.hpp @@ -212,7 +212,7 @@ class BinaryHeap void DeleteAll() { auto iend = heap.end(); - for (typename std::vector::iterator i = heap.begin() + 1; i != iend; ++i) + for (auto i = heap.begin() + 1; i != iend; ++i) { inserted_nodes[i->index].key = 0; } @@ -237,7 +237,9 @@ class BinaryHeap class HeapNode { public: - HeapNode(NodeID n, Key k, Weight w, Data d) : node(n), key(k), weight(w), data(d) {} + HeapNode(NodeID n, Key k, Weight w, Data d) : node(n), key(k), weight(w), data(std::move(d)) + { + } NodeID node; Key key; diff --git a/data_structures/query_edge.hpp b/data_structures/query_edge.hpp index 417bb4a13f9..1c4af03d9c4 100644 --- a/data_structures/query_edge.hpp +++ b/data_structures/query_edge.hpp @@ -58,7 +58,7 @@ struct QueryEdge QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {} QueryEdge(NodeID source, NodeID target, EdgeData data) - : source(source), target(target), data(data) + : source(source), target(target), data(std::move(data)) { } diff --git a/data_structures/segment_information.hpp b/data_structures/segment_information.hpp index 7118a320e85..b22254f02b8 100644 --- a/data_structures/segment_information.hpp +++ b/data_structures/segment_information.hpp @@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../typedefs.h" #include +#include // Struct fits everything in one cache line struct SegmentInformation @@ -48,7 +49,7 @@ struct SegmentInformation bool necessary; bool is_via_location; - explicit SegmentInformation(const FixedPointCoordinate &location, + explicit SegmentInformation(FixedPointCoordinate location, const NodeID name_id, const EdgeWeight duration, const float length, @@ -56,20 +57,20 @@ struct SegmentInformation const bool necessary, const bool is_via_location, const TravelMode travel_mode) - : location(location), name_id(name_id), duration(duration), length(length), bearing(0), - turn_instruction(turn_instruction), travel_mode(travel_mode), necessary(necessary), - is_via_location(is_via_location) + : location(std::move(location)), name_id(name_id), duration(duration), length(length), + bearing(0), turn_instruction(turn_instruction), travel_mode(travel_mode), + necessary(necessary), is_via_location(is_via_location) { } - explicit SegmentInformation(const FixedPointCoordinate &location, + explicit SegmentInformation(FixedPointCoordinate location, const NodeID name_id, const EdgeWeight duration, const float length, const TurnInstruction turn_instruction, const TravelMode travel_mode) - : location(location), name_id(name_id), duration(duration), length(length), bearing(0), - turn_instruction(turn_instruction), travel_mode(travel_mode), + : location(std::move(location)), name_id(name_id), duration(duration), length(length), + bearing(0), turn_instruction(turn_instruction), travel_mode(travel_mode), necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false) { } diff --git a/data_structures/shared_memory_factory.hpp b/data_structures/shared_memory_factory.hpp index 58fed9bb3f5..7d92eaaa596 100644 --- a/data_structures/shared_memory_factory.hpp +++ b/data_structures/shared_memory_factory.hpp @@ -126,7 +126,7 @@ class SharedMemory shm = boost::interprocess::xsi_shared_memory(boost::interprocess::open_or_create, key, size); #ifdef __linux__ - if (-1 == shmctl(shm.get_shmid(), SHM_LOCK, 0)) + if (-1 == shmctl(shm.get_shmid(), SHM_LOCK, nullptr)) { if (ENOMEM == errno) { diff --git a/data_structures/static_rtree.hpp b/data_structures/static_rtree.hpp index 8c05cf52183..e5b7be92cbf 100644 --- a/data_structures/static_rtree.hpp +++ b/data_structures/static_rtree.hpp @@ -316,8 +316,8 @@ class StaticRTree using IncrementalQueryNodeType = mapbox::util::variant; struct IncrementalQueryCandidate { - explicit IncrementalQueryCandidate(const float dist, const IncrementalQueryNodeType &node) - : min_dist(dist), node(node) + explicit IncrementalQueryCandidate(const float dist, IncrementalQueryNodeType node) + : min_dist(dist), node(std::move(node)) { } @@ -553,7 +553,7 @@ class StaticRTree const boost::filesystem::path &leaf_file, std::shared_ptr coordinate_list) : m_search_tree(tree_node_ptr, number_of_nodes), m_leaf_node_filename(leaf_file.string()), - m_coordinate_list(coordinate_list) + m_coordinate_list(std::move(coordinate_list)) { // open leaf node file and store thread specific pointer if (!boost::filesystem::exists(leaf_file)) diff --git a/extractor/extractor.hpp b/extractor/extractor.hpp index 72defca05f9..bc822413d9d 100644 --- a/extractor/extractor.hpp +++ b/extractor/extractor.hpp @@ -33,8 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class extractor { public: - extractor(const ExtractorConfig &extractor_config) - : config(extractor_config) {} + extractor(ExtractorConfig extractor_config) : config(std::move(extractor_config)) {} int run(); private: ExtractorConfig config; diff --git a/extractor/internal_extractor_edge.hpp b/extractor/internal_extractor_edge.hpp index 462bd3531d8..2dc3c3488ee 100644 --- a/extractor/internal_extractor_edge.hpp +++ b/extractor/internal_extractor_edge.hpp @@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include struct InternalExtractorEdge { @@ -68,18 +69,26 @@ struct InternalExtractorEdge } explicit InternalExtractorEdge(NodeID source, - NodeID target, - NodeID name_id, - const WeightData& weight_data, - bool forward, - bool backward, - bool roundabout, - bool access_restricted, - TravelMode travel_mode, - bool is_split) - : result(source, target, name_id, 0, forward, backward, roundabout, - access_restricted, travel_mode, is_split), - weight_data(weight_data) + NodeID target, + NodeID name_id, + WeightData weight_data, + bool forward, + bool backward, + bool roundabout, + bool access_restricted, + TravelMode travel_mode, + bool is_split) + : result(source, + target, + name_id, + 0, + forward, + backward, + roundabout, + access_restricted, + travel_mode, + is_split), + weight_data(std::move(weight_data)) { } diff --git a/include/osrm/json_container.hpp b/include/osrm/json_container.hpp index 40f39b82570..63accb81c0c 100644 --- a/include/osrm/json_container.hpp +++ b/include/osrm/json_container.hpp @@ -50,7 +50,7 @@ struct String { String() {} String(const char *value) : value(value) {} - String(const std::string &value) : value(value) {} + String(std::string value) : value(std::move(value)) {} std::string value; }; diff --git a/include/osrm/libosrm_config.hpp b/include/osrm/libosrm_config.hpp index 67caa399737..83772d0a5dd 100644 --- a/include/osrm/libosrm_config.hpp +++ b/include/osrm/libosrm_config.hpp @@ -39,8 +39,11 @@ struct libosrm_config { } - libosrm_config(const ServerPaths &paths, const bool sharedmemory_flag, const int max_table, const int max_matching) - : server_paths(paths), max_locations_distance_table(max_table), + libosrm_config(ServerPaths paths, + const bool sharedmemory_flag, + const int max_table, + const int max_matching) + : server_paths(std::move(paths)), max_locations_distance_table(max_table), max_locations_map_matching(max_matching), use_shared_memory(sharedmemory_flag) { } diff --git a/plugins/match.hpp b/plugins/match.hpp index a866947b4bc..b0138247c7e 100644 --- a/plugins/match.hpp +++ b/plugins/match.hpp @@ -73,7 +73,7 @@ template class MapMatchingPlugin : public BasePlugin virtual ~MapMatchingPlugin() {} - const std::string GetDescriptor() const final { return descriptor_string; } + const std::string GetDescriptor() const final override { return descriptor_string; } TraceClassification classify(const float trace_length, const float matched_length, const int removed_points) const @@ -211,7 +211,7 @@ template class MapMatchingPlugin : public BasePlugin } int HandleRequest(const RouteParameters &route_parameters, - osrm::json::Object &json_result) final + osrm::json::Object &json_result) final override { // check number of parameters if (!check_all_coordinates(route_parameters.coordinates)) diff --git a/routed.cpp b/routed.cpp index 294efa8f180..c8186f7c93e 100644 --- a/routed.cpp +++ b/routed.cpp @@ -136,12 +136,12 @@ int main(int argc, const char *argv[]) #ifndef _WIN32 sigset_t wait_mask; - pthread_sigmask(SIG_SETMASK, &old_mask, 0); + pthread_sigmask(SIG_SETMASK, &old_mask, nullptr); sigemptyset(&wait_mask); sigaddset(&wait_mask, SIGINT); sigaddset(&wait_mask, SIGQUIT); sigaddset(&wait_mask, SIGTERM); - pthread_sigmask(SIG_BLOCK, &wait_mask, 0); + pthread_sigmask(SIG_BLOCK, &wait_mask, nullptr); SimpleLogger().Write() << "running and waiting for requests"; sigwait(&wait_mask, &sig); #else diff --git a/server/data_structures/internal_datafacade.hpp b/server/data_structures/internal_datafacade.hpp index 823ac3329b8..7439cb8318a 100644 --- a/server/data_structures/internal_datafacade.hpp +++ b/server/data_structures/internal_datafacade.hpp @@ -264,7 +264,7 @@ template class InternalDataFacade final : public BaseDataFacad throw osrm::exception("no names file given in ini file"); } - ServerPaths::const_iterator paths_iterator = server_paths.find("hsgrdata"); + auto paths_iterator = server_paths.find("hsgrdata"); BOOST_ASSERT(server_paths.end() != paths_iterator); const boost::filesystem::path &hsgr_path = paths_iterator->second; paths_iterator = server_paths.find("timestamp"); diff --git a/server/http/header.hpp b/server/http/header.hpp index 08d2476b188..f2598ba1ed7 100644 --- a/server/http/header.hpp +++ b/server/http/header.hpp @@ -37,7 +37,7 @@ struct header { // explicitly use default copy c'tor as adding move c'tor header &operator=(const header &other) = default; - header(const std::string &name, const std::string &value) : name(name), value(value) {} + header(std::string name, std::string value) : name(std::move(name)), value(std::move(value)) {} header(header &&other) : name(std::move(other.name)), value(std::move(other.value)) {} void clear() diff --git a/util/datastore_options.hpp b/util/datastore_options.hpp index 76edc782799..9f16c5757ee 100644 --- a/util/datastore_options.hpp +++ b/util/datastore_options.hpp @@ -146,7 +146,7 @@ bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &p } // parse config file - ServerPaths::iterator path_iterator = paths.find("config"); + auto path_iterator = paths.find("config"); if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) && !option_variables.count("base")) { diff --git a/util/matching_debug_info.hpp b/util/matching_debug_info.hpp index faf878e3f9e..de48a84cfbb 100644 --- a/util/matching_debug_info.hpp +++ b/util/matching_debug_info.hpp @@ -54,16 +54,16 @@ struct MatchingDebugInfo } osrm::json::Array states; - for (unsigned t = 0; t < candidates_list.size(); t++) + for (auto &elem : candidates_list) { osrm::json::Array timestamps; - for (unsigned s = 0; s < candidates_list[t].size(); s++) + for (unsigned s = 0; s < elem.size(); s++) { osrm::json::Object state; state.values["transitions"] = osrm::json::Array(); - state.values["coordinate"] = osrm::json::make_array( - candidates_list[t][s].first.location.lat / COORDINATE_PRECISION, - candidates_list[t][s].first.location.lon / COORDINATE_PRECISION); + state.values["coordinate"] = + 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; diff --git a/util/osrm_exception.hpp b/util/osrm_exception.hpp index e9a01381ee9..369433f3437 100644 --- a/util/osrm_exception.hpp +++ b/util/osrm_exception.hpp @@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include namespace osrm { @@ -37,14 +38,14 @@ class exception final : public std::exception { public: explicit exception(const char *message) : message(message) {} - explicit exception(const std::string &message) : message(message) {} + explicit exception(std::string message) : message(std::move(message)) {} private: // This function exists to 'anchor' the class, and stop the compiler from // copying vtable and RTTI info into every object file that includes // this header. (Caught by -Wweak-vtables under Clang.) virtual void anchor() const; - const char *what() const noexcept { return message.c_str(); } + const char *what() const noexcept override { return message.c_str(); } const std::string message; }; } diff --git a/util/routed_options.hpp b/util/routed_options.hpp index 046ab71b318..106ea23f2ef 100644 --- a/util/routed_options.hpp +++ b/util/routed_options.hpp @@ -243,7 +243,7 @@ inline unsigned GenerateServerProgramOptions(const int argc, boost::program_options::notify(option_variables); // parse config file - ServerPaths::iterator path_iterator = paths.find("config"); + auto path_iterator = paths.find("config"); if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) && !option_variables.count("base")) {