From 0021ccef59c633481bb2e81d9d12d3b5ee440c41 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 13:59:59 +0100 Subject: [PATCH 01/23] Replace boost::string_ref with std::string_view --- include/engine/api/base_api.hpp | 6 +-- include/engine/guidance/assemble_leg.hpp | 4 +- include/engine/guidance/assemble_steps.hpp | 40 ++++++++++---------- include/util/guidance/name_announcements.hpp | 5 ++- include/util/string_view.hpp | 4 +- src/engine/plugins/tile.cpp | 6 +-- 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/include/engine/api/base_api.hpp b/include/engine/api/base_api.hpp index 086c787de..9e43d311c 100644 --- a/include/engine/api/base_api.hpp +++ b/include/engine/api/base_api.hpp @@ -57,8 +57,7 @@ class BaseAPI { // TODO: check forward/reverse const auto toName = [this](const auto &phantom) { - return facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)) - .to_string(); + return std::string(facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))); }; const auto noEmpty = [](const auto &name) { return !name.empty(); }; @@ -128,8 +127,7 @@ class BaseAPI static_cast(static_cast(util::toFloating(snapped_location.lat)))); const auto toName = [this](const auto &phantom) { - return facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)) - .to_string(); + return std::string(facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))); }; const auto noEmpty = [](const auto &name) { return !name.empty(); }; diff --git a/include/engine/guidance/assemble_leg.hpp b/include/engine/guidance/assemble_leg.hpp index 19e7ebffe..595f09b99 100644 --- a/include/engine/guidance/assemble_leg.hpp +++ b/include/engine/guidance/assemble_leg.hpp @@ -145,11 +145,11 @@ inline std::string assembleSummary(const datafacade::BaseDataFacade &facade, const auto name_id_to_string = [&](const NameID name_id) { const auto name = facade.GetNameForID(name_id); if (!name.empty()) - return name.to_string(); + return std::string(name); else { const auto ref = facade.GetRefForID(name_id); - return ref.to_string(); + return std::string(ref); } }; diff --git a/include/engine/guidance/assemble_steps.hpp b/include/engine/guidance/assemble_steps.hpp index 18e09d972..2f1b06924 100644 --- a/include/engine/guidance/assemble_steps.hpp +++ b/include/engine/guidance/assemble_steps.hpp @@ -140,11 +140,11 @@ inline std::vector assembleSteps(const datafacade::BaseDataFacade &fa steps.push_back(RouteStep{path_point.from_edge_based_node, step_name_id, is_segregated, - name.to_string(), - ref.to_string(), - pronunciation.to_string(), - destinations.to_string(), - exits.to_string(), + std::string(name), + std::string(ref), + std::string(pronunciation), + std::string(destinations), + std::string(exits), NO_ROTARY_NAME, NO_ROTARY_NAME, from_alias(segment_duration) / 10., @@ -241,11 +241,11 @@ inline std::vector assembleSteps(const datafacade::BaseDataFacade &fa steps.push_back(RouteStep{leg_data[leg_data.size() - 1].from_edge_based_node, step_name_id, is_segregated, - facade.GetNameForID(step_name_id).to_string(), - facade.GetRefForID(step_name_id).to_string(), - facade.GetPronunciationForID(step_name_id).to_string(), - facade.GetDestinationsForID(step_name_id).to_string(), - facade.GetExitsForID(step_name_id).to_string(), + std::string(facade.GetNameForID(step_name_id)), + std::string(facade.GetRefForID(step_name_id)), + std::string(facade.GetPronunciationForID(step_name_id)), + std::string(facade.GetDestinationsForID(step_name_id)), + std::string(facade.GetExitsForID(step_name_id)), NO_ROTARY_NAME, NO_ROTARY_NAME, from_alias(duration) / 10., @@ -287,11 +287,11 @@ inline std::vector assembleSteps(const datafacade::BaseDataFacade &fa steps.push_back(RouteStep{source_node_id, source_name_id, is_segregated, - facade.GetNameForID(source_name_id).to_string(), - facade.GetRefForID(source_name_id).to_string(), - facade.GetPronunciationForID(source_name_id).to_string(), - facade.GetDestinationsForID(source_name_id).to_string(), - facade.GetExitsForID(source_name_id).to_string(), + std::string(facade.GetNameForID(source_name_id)), + std::string(facade.GetRefForID(source_name_id)), + std::string(facade.GetPronunciationForID(source_name_id)), + std::string(facade.GetDestinationsForID(source_name_id)), + std::string(facade.GetExitsForID(source_name_id)), NO_ROTARY_NAME, NO_ROTARY_NAME, from_alias(duration) / 10., @@ -330,11 +330,11 @@ inline std::vector assembleSteps(const datafacade::BaseDataFacade &fa steps.push_back(RouteStep{target_node_id, target_name_id, facade.IsSegregated(target_node_id), - facade.GetNameForID(target_name_id).to_string(), - facade.GetRefForID(target_name_id).to_string(), - facade.GetPronunciationForID(target_name_id).to_string(), - facade.GetDestinationsForID(target_name_id).to_string(), - facade.GetExitsForID(target_name_id).to_string(), + std::string(facade.GetNameForID(target_name_id)), + std::string(facade.GetRefForID(target_name_id)), + std::string(facade.GetPronunciationForID(target_name_id)), + std::string(facade.GetDestinationsForID(target_name_id)), + std::string(facade.GetExitsForID(target_name_id)), NO_ROTARY_NAME, NO_ROTARY_NAME, ZERO_DURATION, diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index fa8f9db43..2b2b3794b 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -70,7 +70,10 @@ template inline auto decompose(const StringView &lhs, cons const auto trim = [](StringView view) { // we compare suffixes based on this value, it might break UTF chars, but as long as we are // consistent in handling, we do not create bad results - std::string str = boost::to_lower_copy(view.to_string()); + std::string str(view); + std::transform(str.begin(), str.end(), str.begin(), + [](unsigned char c){ return std::tolower(c); } // correct + ); auto front = str.find_first_not_of(' '); if (front == std::string::npos) diff --git a/include/util/string_view.hpp b/include/util/string_view.hpp index c7ab0df3d..d1cf4cb96 100644 --- a/include/util/string_view.hpp +++ b/include/util/string_view.hpp @@ -2,14 +2,14 @@ #define OSRM_STRING_VIEW_HPP #include -#include +#include namespace osrm { namespace util { // Convenience typedef: boost::string_ref, boost::string_view or C++17's string_view -using StringView = boost::string_ref; +using StringView = std::string_view; } // namespace util } // namespace osrm diff --git a/src/engine/plugins/tile.cpp b/src/engine/plugins/tile.cpp index f932abe73..d69dacec5 100644 --- a/src/engine/plugins/tile.cpp +++ b/src/engine/plugins/tile.cpp @@ -340,7 +340,7 @@ class SpeedLayerFeatureBuilder : public vtzero::linestring_feature_builder add_property(m_layer.key_duration, m_layer.double_index(value)); } - void set_name(const boost::string_ref &value) + void set_name(const std::string_view value) { add_property( m_layer.key_name, @@ -518,7 +518,7 @@ void encodeVectorTile(const DataFacadeBase &facade, fbuilder.set_speed(speed_kmh_idx); fbuilder.set_is_small(component_id.is_tiny); fbuilder.set_datasource( - facade.GetDatasourceName(forward_datasource_idx).to_string()); + std::string(facade.GetDatasourceName(forward_datasource_idx))); fbuilder.set_weight(from_alias(forward_weight) / 10.0); fbuilder.set_duration(from_alias(forward_duration) / 10.0); fbuilder.set_name(name); @@ -552,7 +552,7 @@ void encodeVectorTile(const DataFacadeBase &facade, fbuilder.set_speed(speed_kmh_idx); fbuilder.set_is_small(component_id.is_tiny); fbuilder.set_datasource( - facade.GetDatasourceName(reverse_datasource_idx).to_string()); + std::string(facade.GetDatasourceName(reverse_datasource_idx))); fbuilder.set_weight(from_alias(reverse_weight) / 10.0); fbuilder.set_duration(from_alias(reverse_duration) / 10.0); fbuilder.set_name(name); From 91e9623b31a61ca5f3188ee60dfb50737d6036ac Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 14:06:19 +0100 Subject: [PATCH 02/23] Fix formatting --- include/engine/api/base_api.hpp | 8 +++++--- include/util/guidance/name_announcements.hpp | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/engine/api/base_api.hpp b/include/engine/api/base_api.hpp index 9e43d311c..556b3e41c 100644 --- a/include/engine/api/base_api.hpp +++ b/include/engine/api/base_api.hpp @@ -57,7 +57,8 @@ class BaseAPI { // TODO: check forward/reverse const auto toName = [this](const auto &phantom) { - return std::string(facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))); + return std::string( + facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))); }; const auto noEmpty = [](const auto &name) { return !name.empty(); }; @@ -127,8 +128,9 @@ class BaseAPI static_cast(static_cast(util::toFloating(snapped_location.lat)))); const auto toName = [this](const auto &phantom) { - return std::string(facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))); - }; + return std::string( + facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))); + }; const auto noEmpty = [](const auto &name) { return !name.empty(); }; // At an intersection we may have multiple phantom node candidates. diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index 2b2b3794b..3fee48512 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -71,8 +71,10 @@ template inline auto decompose(const StringView &lhs, cons // we compare suffixes based on this value, it might break UTF chars, but as long as we are // consistent in handling, we do not create bad results std::string str(view); - std::transform(str.begin(), str.end(), str.begin(), - [](unsigned char c){ return std::tolower(c); } // correct + std::transform(str.begin(), + str.end(), + str.begin(), + [](unsigned char c) { return std::tolower(c); } ); auto front = str.find_first_not_of(' '); From d06b23d819ff2aea50a38abd189e8aaadce8a97c Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 14:08:17 +0100 Subject: [PATCH 03/23] More fixes --- include/engine/api/base_api.hpp | 2 +- include/util/guidance/name_announcements.hpp | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/engine/api/base_api.hpp b/include/engine/api/base_api.hpp index 556b3e41c..0cd066d0f 100644 --- a/include/engine/api/base_api.hpp +++ b/include/engine/api/base_api.hpp @@ -130,7 +130,7 @@ class BaseAPI const auto toName = [this](const auto &phantom) { return std::string( facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))); - }; + }; const auto noEmpty = [](const auto &name) { return !name.empty(); }; // At an intersection we may have multiple phantom node candidates. diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index 3fee48512..112da7f8c 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -71,10 +71,8 @@ template inline auto decompose(const StringView &lhs, cons // we compare suffixes based on this value, it might break UTF chars, but as long as we are // consistent in handling, we do not create bad results std::string str(view); - std::transform(str.begin(), - str.end(), - str.begin(), - [](unsigned char c) { return std::tolower(c); } + std::transform( + str.begin(), str.end(), str.begin(), [](unsigned char c) { return std::tolower(c); }); ); auto front = str.find_first_not_of(' '); From 274dcc58a5fc6db5931cb990608a246d1e2deaf6 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 19:21:06 +0100 Subject: [PATCH 04/23] Remove superflous std::hash specialization --- include/util/guidance/name_announcements.hpp | 1 - include/util/string_view.hpp | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index 112da7f8c..fceff6b03 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -73,7 +73,6 @@ template inline auto decompose(const StringView &lhs, cons std::string str(view); std::transform( str.begin(), str.end(), str.begin(), [](unsigned char c) { return std::tolower(c); }); - ); auto front = str.find_first_not_of(' '); if (front == std::string::npos) diff --git a/include/util/string_view.hpp b/include/util/string_view.hpp index d1cf4cb96..21f34ca5c 100644 --- a/include/util/string_view.hpp +++ b/include/util/string_view.hpp @@ -14,21 +14,4 @@ using StringView = std::string_view; } // namespace util } // namespace osrm -// Specializing hash<> for user-defined type in std namespace, this is standard conforming. -namespace std -{ -template <> struct hash<::osrm::util::StringView> final -{ - std::size_t operator()(::osrm::util::StringView v) const noexcept - { - // Bring into scope and call un-qualified for ADL: - // remember we want to be able to switch impl. above. - using std::begin; - using std::end; - - return boost::hash_range(begin(v), end(v)); - } -}; -} // namespace std - #endif /* OSRM_STRING_VIEW_HPP */ From 5c9d0d152c1f26f2d328363345ba8538b1b84ee7 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 19:52:57 +0100 Subject: [PATCH 05/23] Remove usage of StringView typedef --- .../contiguous_internalmem_datafacade.hpp | 14 +++++------ include/engine/datafacade/datafacade_base.hpp | 14 +++++------ include/extractor/datasources.hpp | 4 ++-- include/extractor/name_table.hpp | 12 +++++----- include/extractor/suffix_table.hpp | 4 ++-- include/storage/view_factory.hpp | 2 +- include/util/guidance/name_announcements.hpp | 24 +++++++++---------- include/util/indexed_data.hpp | 4 ++-- include/util/string_view.hpp | 2 +- src/extractor/suffix_table.cpp | 6 ++--- ...segregated_intersection_classification.cpp | 2 +- unit_tests/engine/offline_facade.cpp | 12 +++++----- unit_tests/mocks/mock_datafacade.hpp | 14 +++++------ unit_tests/util/indexed_data.cpp | 2 +- 14 files changed, 56 insertions(+), 60 deletions(-) diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 0548e0569..48d00e0c1 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -142,7 +142,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade extractor::Datasources *m_datasources; std::uint32_t m_check_sum; - StringView m_data_timestamp; + std::string_view m_data_timestamp; util::vector_view m_coordinate_list; extractor::PackedOSMIDsView m_osmnodeid_list; util::vector_view m_lane_description_offsets; @@ -408,32 +408,32 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade return edge_based_node_data.GetNameID(edge_based_node_id); } - StringView GetNameForID(const NameID id) const override final + std::string_view GetNameForID(const NameID id) const override final { return m_name_table.GetNameForID(id); } - StringView GetRefForID(const NameID id) const override final + std::string_view GetRefForID(const NameID id) const override final { return m_name_table.GetRefForID(id); } - StringView GetPronunciationForID(const NameID id) const override final + std::string_view GetPronunciationForID(const NameID id) const override final { return m_name_table.GetPronunciationForID(id); } - StringView GetDestinationsForID(const NameID id) const override final + std::string_view GetDestinationsForID(const NameID id) const override final { return m_name_table.GetDestinationsForID(id); } - StringView GetExitsForID(const NameID id) const override final + std::string_view GetExitsForID(const NameID id) const override final { return m_name_table.GetExitsForID(id); } - StringView GetDatasourceName(const DatasourceID id) const override final + std::string_view GetDatasourceName(const DatasourceID id) const override final { return m_datasources->GetSourceName(id); } diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index 936ccf0c2..7e9e69c88 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -47,8 +47,6 @@ namespace engine namespace datafacade { -using StringView = util::StringView; - class BaseDataFacade { public: @@ -113,7 +111,7 @@ class BaseDataFacade GetUncompressedReverseDatasources(const PackedGeometryID id) const = 0; // Gets the name of a datasource - virtual StringView GetDatasourceName(const DatasourceID id) const = 0; + virtual std::string_view GetDatasourceName(const DatasourceID id) const = 0; virtual osrm::guidance::TurnInstruction GetTurnInstructionForEdgeID(const EdgeID edge_based_edge_id) const = 0; @@ -157,15 +155,15 @@ class BaseDataFacade virtual NameID GetNameIndex(const NodeID edge_based_node_id) const = 0; - virtual StringView GetNameForID(const NameID id) const = 0; + virtual std::string_view GetNameForID(const NameID id) const = 0; - virtual StringView GetRefForID(const NameID id) const = 0; + virtual std::string_view GetRefForID(const NameID id) const = 0; - virtual StringView GetPronunciationForID(const NameID id) const = 0; + virtual std::string_view GetPronunciationForID(const NameID id) const = 0; - virtual StringView GetDestinationsForID(const NameID id) const = 0; + virtual std::string_view GetDestinationsForID(const NameID id) const = 0; - virtual StringView GetExitsForID(const NameID id) const = 0; + virtual std::string_view GetExitsForID(const NameID id) const = 0; virtual bool GetContinueStraightDefault() const = 0; diff --git a/include/extractor/datasources.hpp b/include/extractor/datasources.hpp index a4f872656..844ceae0f 100644 --- a/include/extractor/datasources.hpp +++ b/include/extractor/datasources.hpp @@ -22,11 +22,11 @@ class Datasources std::fill(sources.begin(), sources.end(), '\0'); } - util::StringView GetSourceName(DatasourceID id) const + std::string_view GetSourceName(DatasourceID id) const { auto begin = sources.data() + (MAX_LENGTH_NAME * id); - return util::StringView{begin, lengths[id]}; + return std::string_view{begin, lengths[id]}; } void SetSourceName(DatasourceID id, const std::string &name) diff --git a/include/extractor/name_table.hpp b/include/extractor/name_table.hpp index ff0d27ae1..35e966ee1 100644 --- a/include/extractor/name_table.hpp +++ b/include/extractor/name_table.hpp @@ -50,7 +50,7 @@ template class NameTableImpl { public: using IndexedData = - util::detail::IndexedDataImpl, Ownership>; + util::detail::IndexedDataImpl, Ownership>; using ResultType = typename IndexedData::ResultType; using ValueType = typename IndexedData::ValueType; @@ -58,7 +58,7 @@ template class NameTableImpl NameTableImpl(IndexedData indexed_data_) : indexed_data{std::move(indexed_data_)} {} - util::StringView GetNameForID(const NameID id) const + std::string_view GetNameForID(const NameID id) const { if (id == INVALID_NAMEID) return {}; @@ -66,7 +66,7 @@ template class NameTableImpl return indexed_data.at(id + 0); } - util::StringView GetDestinationsForID(const NameID id) const + std::string_view GetDestinationsForID(const NameID id) const { if (id == INVALID_NAMEID) return {}; @@ -74,7 +74,7 @@ template class NameTableImpl return indexed_data.at(id + 1); } - util::StringView GetExitsForID(const NameID id) const + std::string_view GetExitsForID(const NameID id) const { if (id == INVALID_NAMEID) return {}; @@ -82,7 +82,7 @@ template class NameTableImpl return indexed_data.at(id + 4); } - util::StringView GetRefForID(const NameID id) const + std::string_view GetRefForID(const NameID id) const { if (id == INVALID_NAMEID) return {}; @@ -91,7 +91,7 @@ template class NameTableImpl return indexed_data.at(id + OFFSET_REF); } - util::StringView GetPronunciationForID(const NameID id) const + std::string_view GetPronunciationForID(const NameID id) const { if (id == INVALID_NAMEID) return {}; diff --git a/include/extractor/suffix_table.hpp b/include/extractor/suffix_table.hpp index 5d16fe6b7..52dc4eec4 100644 --- a/include/extractor/suffix_table.hpp +++ b/include/extractor/suffix_table.hpp @@ -23,7 +23,7 @@ class SuffixTable final // check whether a string is part of the know suffix list bool isSuffix(const std::string &possible_suffix) const; - bool isSuffix(util::StringView possible_suffix) const; + bool isSuffix(std::string_view possible_suffix) const; private: // Store lower-cased strings in SuffixTable and a set of StringViews for quick membership @@ -36,7 +36,7 @@ class SuffixTable final // require us to first convert StringViews into strings (allocation), do the membership, // and destroy the StringView again. std::vector suffixes; - std::unordered_set suffix_set; + std::unordered_set suffix_set; }; } /* namespace extractor */ diff --git a/include/storage/view_factory.hpp b/include/storage/view_factory.hpp index bbc490ce3..80db376bf 100644 --- a/include/storage/view_factory.hpp +++ b/include/storage/view_factory.hpp @@ -263,7 +263,7 @@ inline auto make_partition_view(const SharedDataIndex &index, const std::string inline auto make_timestamp_view(const SharedDataIndex &index, const std::string &name) { - return util::StringView(index.GetBlockPtr(name), index.GetBlockEntries(name)); + return std::string_view(index.GetBlockPtr(name), index.GetBlockEntries(name)); } inline auto make_cell_storage_view(const SharedDataIndex &index, const std::string &name) diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index fceff6b03..06639310d 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -27,8 +27,8 @@ namespace guidance // Name Change Logic // Used both during Extraction as well as during Post-Processing -inline util::StringView longest_common_substring(const util::StringView &lhs, - const util::StringView &rhs) +inline std::string_view longest_common_substring(const std::string_view &lhs, + const std::string_view &rhs) { if (lhs.empty() || rhs.empty()) return ""; @@ -132,7 +132,7 @@ inline bool requiresNameAnnounced(const StringView &from_name, boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name); const auto checkForPrefixOrSuffixChange = - [](const StringView &first, const StringView &second, const SuffixTable &suffix_table) { + [](const std::string_view &first, const std::string_view &second, const SuffixTable &suffix_table) { std::string first_prefix, first_suffix, second_prefix, second_suffix; std::tie(first_prefix, first_suffix, second_prefix, second_suffix) = decompose(first, second); @@ -203,17 +203,17 @@ inline bool requiresNameAnnounced(const std::string &from_name, struct NopSuffixTable final { NopSuffixTable() {} - bool isSuffix(const StringView &) const { return false; } + bool isSuffix(const std::string_view &) const { return false; } } static const table; - return requiresNameAnnounced(util::StringView(from_name), - util::StringView(from_ref), - util::StringView(from_pronunciation), - util::StringView(from_exits), - util::StringView(to_name), - util::StringView(to_ref), - util::StringView(to_pronunciation), - util::StringView(to_exits), + return requiresNameAnnounced(std::string_view(from_name), + std::string_view(from_ref), + std::string_view(from_pronunciation), + std::string_view(from_exits), + std::string_view(to_name), + std::string_view(to_ref), + std::string_view(to_pronunciation), + std::string_view(to_exits), table); } diff --git a/include/util/indexed_data.hpp b/include/util/indexed_data.hpp index 5ce5bd4b3..d62105d42 100644 --- a/include/util/indexed_data.hpp +++ b/include/util/indexed_data.hpp @@ -365,14 +365,14 @@ template struct Indexe std::enable_if_t::value_type>::value>; template > - typename std::enable_if::value, T>::type + typename std::enable_if::value, T>::type adapt(const Iter first, const Iter last) const { return ResultType(first, last); } template > - typename std::enable_if::value, T>::type + typename std::enable_if::value, T>::type adapt(const Iter first, const Iter last) const { auto diff = std::distance(first, last); diff --git a/include/util/string_view.hpp b/include/util/string_view.hpp index 21f34ca5c..77cbdb200 100644 --- a/include/util/string_view.hpp +++ b/include/util/string_view.hpp @@ -9,7 +9,7 @@ namespace osrm namespace util { // Convenience typedef: boost::string_ref, boost::string_view or C++17's string_view -using StringView = std::string_view; +// using StringView = std::string_view; } // namespace util } // namespace osrm diff --git a/src/extractor/suffix_table.cpp b/src/extractor/suffix_table.cpp index 26f9afd91..a835562f9 100644 --- a/src/extractor/suffix_table.cpp +++ b/src/extractor/suffix_table.cpp @@ -19,16 +19,16 @@ SuffixTable::SuffixTable(ScriptingEnvironment &scripting_environment) boost::algorithm::to_lower(suffix); auto into = std::inserter(suffix_set, end(suffix_set)); - auto to_view = [](const auto &s) { return util::StringView{s}; }; + auto to_view = [](const auto &s) { return std::string_view{s}; }; std::transform(begin(suffixes), end(suffixes), into, to_view); } bool SuffixTable::isSuffix(const std::string &possible_suffix) const { - return isSuffix(util::StringView{possible_suffix}); + return isSuffix(std::string_view{possible_suffix}); } -bool SuffixTable::isSuffix(util::StringView possible_suffix) const +bool SuffixTable::isSuffix(std::string_view possible_suffix) const { return suffix_set.count(possible_suffix) > 0; } diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index b87d19a35..f9411a912 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -24,7 +24,7 @@ struct EdgeInfo NodeID node; - util::StringView name; + std::string_view name; bool reversed; diff --git a/unit_tests/engine/offline_facade.cpp b/unit_tests/engine/offline_facade.cpp index e4b0a2be7..df30dc9a4 100644 --- a/unit_tests/engine/offline_facade.cpp +++ b/unit_tests/engine/offline_facade.cpp @@ -203,7 +203,7 @@ class ContiguousInternalMemoryDataFacade return DatasourceReverseRange(DatasourceForwardRange()); } - StringView GetDatasourceName(const DatasourceID /*id*/) const override { return StringView{}; } + std::string_view GetDatasourceName(const DatasourceID /*id*/) const override { return std::string_view{}; } guidance::TurnInstruction GetTurnInstructionForEdgeID(const EdgeID /*id*/) const override { @@ -270,11 +270,11 @@ class ContiguousInternalMemoryDataFacade bool HasLaneData(const EdgeID /*id*/) const override { return false; } NameID GetNameIndex(const NodeID /*nodeID*/) const override { return EMPTY_NAMEID; } - StringView GetNameForID(const NameID /*id*/) const override { return StringView{}; } - StringView GetRefForID(const NameID /*id*/) const override { return StringView{}; } - StringView GetPronunciationForID(const NameID /*id*/) const override { return StringView{}; } - StringView GetDestinationsForID(const NameID /*id*/) const override { return StringView{}; } - StringView GetExitsForID(const NameID /*id*/) const override { return StringView{}; } + std::string_view GetNameForID(const NameID /*id*/) const override { return std::string_view{}; } + std::string_view GetRefForID(const NameID /*id*/) const override { return std::string_view{}; } + std::string_view GetPronunciationForID(const NameID /*id*/) const override { return std::string_view{}; } + std::string_view GetDestinationsForID(const NameID /*id*/) const override { return std::string_view{}; } + std::string_view GetExitsForID(const NameID /*id*/) const override { return std::string_view{}; } bool GetContinueStraightDefault() const override { return false; } std::string GetTimestamp() const override { return ""; } double GetMapMatchingMaxSpeed() const override { return 0; } diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp index bfaf41415..81471835b 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -26,8 +26,6 @@ namespace test class MockBaseDataFacade : public engine::datafacade::BaseDataFacade { - using StringView = util::StringView; - public: bool ExcludeNode(const NodeID) const override { return false; }; @@ -95,7 +93,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade return DatasourceReverseRange(DatasourceForwardRange()); } - StringView GetDatasourceName(const DatasourceID) const override final { return {}; } + std::string_view GetDatasourceName(const DatasourceID) const override final { return {}; } osrm::guidance::TurnInstruction GetTurnInstructionForEdgeID(const EdgeID /* id */) const override @@ -154,11 +152,11 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade NameID GetNameIndex(const NodeID /* id */) const override { return 0; } - StringView GetNameForID(const NameID) const override final { return {}; } - StringView GetRefForID(const NameID) const override final { return {}; } - StringView GetPronunciationForID(const NameID) const override final { return {}; } - StringView GetDestinationsForID(const NameID) const override final { return {}; } - StringView GetExitsForID(const NameID) const override final { return {}; } + std::string_view GetNameForID(const NameID) const override final { return {}; } + std::string_view GetRefForID(const NameID) const override final { return {}; } + std::string_view GetPronunciationForID(const NameID) const override final { return {}; } + std::string_view GetDestinationsForID(const NameID) const override final { return {}; } + std::string_view GetExitsForID(const NameID) const override final { return {}; } bool GetContinueStraightDefault() const override { return true; } double GetMapMatchingMaxSpeed() const override { return 180 / 3.6; } diff --git a/unit_tests/util/indexed_data.cpp b/unit_tests/util/indexed_data.cpp index 6d9eecbe9..40b79f9be 100644 --- a/unit_tests/util/indexed_data.cpp +++ b/unit_tests/util/indexed_data.cpp @@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(check_string_view) std::string name_data = "hellostringview"; std::vector name_offsets = {0, 5, 11, 15}; - IndexedData> indexed_data( + IndexedData> indexed_data( name_offsets.begin(), name_offsets.end(), name_data.begin()); BOOST_CHECK_EQUAL(indexed_data.at(0), "hello"); From 565959b3896945a0eb437cc799b697be023121ef Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 20:01:46 +0100 Subject: [PATCH 06/23] Remove util/string_view header --- include/engine/datafacade/datafacade_base.hpp | 2 +- include/extractor/datasources.hpp | 5 +++-- include/extractor/name_table.hpp | 2 +- include/extractor/suffix_table.hpp | 4 ++-- include/util/indexed_data.hpp | 2 +- include/util/string_view.hpp | 17 ----------------- src/engine/plugins/tile.cpp | 2 +- 7 files changed, 9 insertions(+), 25 deletions(-) delete mode 100644 include/util/string_view.hpp diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index 7e9e69c88..8ecd5946e 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -26,7 +26,6 @@ #include "util/integer_range.hpp" #include "util/packed_vector.hpp" #include "util/string_util.hpp" -#include "util/string_view.hpp" #include "util/typedefs.hpp" #include "osrm/coordinate.hpp" @@ -37,6 +36,7 @@ #include #include +#include #include #include diff --git a/include/extractor/datasources.hpp b/include/extractor/datasources.hpp index 844ceae0f..ea53fc3e4 100644 --- a/include/extractor/datasources.hpp +++ b/include/extractor/datasources.hpp @@ -1,9 +1,10 @@ #ifndef OSRM_EXTRACT_DATASOURCES_HPP #define OSRM_EXTRACT_DATASOURCES_HPP +#include "util/typedefs.hpp" + #include -#include -#include +#include namespace osrm { diff --git a/include/extractor/name_table.hpp b/include/extractor/name_table.hpp index 35e966ee1..44cc06f89 100644 --- a/include/extractor/name_table.hpp +++ b/include/extractor/name_table.hpp @@ -2,10 +2,10 @@ #define OSRM_EXTRACTOR_NAME_TABLE_HPP #include "util/indexed_data.hpp" -#include "util/string_view.hpp" #include "util/typedefs.hpp" #include +#include namespace osrm { diff --git a/include/extractor/suffix_table.hpp b/include/extractor/suffix_table.hpp index 52dc4eec4..cadfb5e2e 100644 --- a/include/extractor/suffix_table.hpp +++ b/include/extractor/suffix_table.hpp @@ -2,9 +2,9 @@ #define OSRM_EXTRACTOR_SUFFIX_LIST_HPP_ #include +#include #include - -#include "util/string_view.hpp" +#include namespace osrm { diff --git a/include/util/indexed_data.hpp b/include/util/indexed_data.hpp index d62105d42..a09425b33 100644 --- a/include/util/indexed_data.hpp +++ b/include/util/indexed_data.hpp @@ -4,7 +4,6 @@ #include "storage/tar_fwd.hpp" #include "util/exception.hpp" -#include "util/string_view.hpp" #include "util/vector_view.hpp" #include @@ -14,6 +13,7 @@ #include #include #include +#include #include namespace osrm diff --git a/include/util/string_view.hpp b/include/util/string_view.hpp deleted file mode 100644 index 77cbdb200..000000000 --- a/include/util/string_view.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef OSRM_STRING_VIEW_HPP -#define OSRM_STRING_VIEW_HPP - -#include -#include - -namespace osrm -{ -namespace util -{ -// Convenience typedef: boost::string_ref, boost::string_view or C++17's string_view -// using StringView = std::string_view; - -} // namespace util -} // namespace osrm - -#endif /* OSRM_STRING_VIEW_HPP */ diff --git a/src/engine/plugins/tile.cpp b/src/engine/plugins/tile.cpp index d69dacec5..94490662a 100644 --- a/src/engine/plugins/tile.cpp +++ b/src/engine/plugins/tile.cpp @@ -4,7 +4,6 @@ #include "engine/plugins/tile.hpp" #include "util/coordinate_calculation.hpp" -#include "util/string_view.hpp" #include "util/vector_tile.hpp" #include "util/web_mercator.hpp" @@ -20,6 +19,7 @@ #include #include #include +#include #include #include From 7149547645317341b642a08be12372ce667953cf Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 20:10:09 +0100 Subject: [PATCH 07/23] Fix formatting --- include/util/guidance/name_announcements.hpp | 24 ++++++++++---------- unit_tests/engine/offline_facade.cpp | 20 ++++++++++++---- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index 06639310d..83f604144 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -131,19 +131,19 @@ inline bool requiresNameAnnounced(const StringView &from_name, const auto name_is_contained = boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name); - const auto checkForPrefixOrSuffixChange = - [](const std::string_view &first, const std::string_view &second, const SuffixTable &suffix_table) { - std::string first_prefix, first_suffix, second_prefix, second_suffix; - std::tie(first_prefix, first_suffix, second_prefix, second_suffix) = - decompose(first, second); - - const auto checkTable = [&](const std::string &str) { - return str.empty() || suffix_table.isSuffix(str); - }; - - return checkTable(first_prefix) && checkTable(first_suffix) && - checkTable(second_prefix) && checkTable(second_suffix); + const auto checkForPrefixOrSuffixChange = [](const std::string_view &first, + const std::string_view &second, + const SuffixTable &suffix_table) { + std::string first_prefix, first_suffix, second_prefix, second_suffix; + std::tie(first_prefix, first_suffix, second_prefix, second_suffix) = + decompose(first, second); + const auto checkTable = [&](const std::string &str) { + return str.empty() || suffix_table.isSuffix(str); }; + + return checkTable(first_prefix) && checkTable(first_suffix) && checkTable(second_prefix) && + checkTable(second_suffix); + }; const auto is_suffix_change = checkForPrefixOrSuffixChange(from_name, to_name, suffix_table); const auto names_are_equal = from_name == to_name || name_is_contained || is_suffix_change; diff --git a/unit_tests/engine/offline_facade.cpp b/unit_tests/engine/offline_facade.cpp index df30dc9a4..afe1c7253 100644 --- a/unit_tests/engine/offline_facade.cpp +++ b/unit_tests/engine/offline_facade.cpp @@ -203,7 +203,10 @@ class ContiguousInternalMemoryDataFacade return DatasourceReverseRange(DatasourceForwardRange()); } - std::string_view GetDatasourceName(const DatasourceID /*id*/) const override { return std::string_view{}; } + std::string_view GetDatasourceName(const DatasourceID /*id*/) const override + { + return std::string_view{}; + } guidance::TurnInstruction GetTurnInstructionForEdgeID(const EdgeID /*id*/) const override { @@ -272,9 +275,18 @@ class ContiguousInternalMemoryDataFacade NameID GetNameIndex(const NodeID /*nodeID*/) const override { return EMPTY_NAMEID; } std::string_view GetNameForID(const NameID /*id*/) const override { return std::string_view{}; } std::string_view GetRefForID(const NameID /*id*/) const override { return std::string_view{}; } - std::string_view GetPronunciationForID(const NameID /*id*/) const override { return std::string_view{}; } - std::string_view GetDestinationsForID(const NameID /*id*/) const override { return std::string_view{}; } - std::string_view GetExitsForID(const NameID /*id*/) const override { return std::string_view{}; } + std::string_view GetPronunciationForID(const NameID /*id*/) const override + { + return std::string_view{}; + } + std::string_view GetDestinationsForID(const NameID /*id*/) const override + { + return std::string_view{}; + } + std::string_view GetExitsForID(const NameID /*id*/) const override + { + return std::string_view{}; + } bool GetContinueStraightDefault() const override { return false; } std::string GetTimestamp() const override { return ""; } double GetMapMatchingMaxSpeed() const override { return 0; } From 12f49d6f24e20d397af2849e4adaa221f9faeb1c Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 20:11:36 +0100 Subject: [PATCH 08/23] Stray whitespace --- include/util/guidance/name_announcements.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index 83f604144..1ebf8a64a 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -140,7 +140,7 @@ inline bool requiresNameAnnounced(const StringView &from_name, const auto checkTable = [&](const std::string &str) { return str.empty() || suffix_table.isSuffix(str); }; - + return checkTable(first_prefix) && checkTable(first_suffix) && checkTable(second_prefix) && checkTable(second_suffix); }; From 85e6a854aa2e3c97d200748b02798bb115673478 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 30 Oct 2022 22:08:29 +0100 Subject: [PATCH 09/23] Fix missing includes (on Windows) --- include/extractor/datasources.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/extractor/datasources.hpp b/include/extractor/datasources.hpp index ea53fc3e4..ded71b611 100644 --- a/include/extractor/datasources.hpp +++ b/include/extractor/datasources.hpp @@ -3,6 +3,8 @@ #include "util/typedefs.hpp" +#include +#include #include #include From 2c02d4e5abde1d67abe7320b9815588041b1365b Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 1 Nov 2022 12:10:48 +0100 Subject: [PATCH 10/23] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf1c10381..56e2d3261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - FIXED: Fix bindings compilation issue on the latest Node. Update NAN to 2.17.0. [#6416](https://github.com/Project-OSRM/osrm-backend/pull/6416) - CHANGED: Make edge metrics strongly typed [#6420](https://github.com/Project-OSRM/osrm-backend/pull/6420) - FIXED: Typo in file name src/util/timed_historgram.cpp -> src/util/timed_histogram.cpp [#6428](https://github.com/Project-OSRM/osrm-backend/issues/6428) + - CHANGED: Replace boost::string_ref with std::string_view [#6433](https://github.com/Project-OSRM/osrm-backend/pull/6433) - Routing: - FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419) # 5.27.1 From 5280ca4e1642085e1520ffff8a842c3cb0124fe7 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 4 Nov 2022 11:41:02 +0100 Subject: [PATCH 11/23] Pass string_view by value --- include/extractor/suffix_table.hpp | 2 +- include/util/guidance/name_announcements.hpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/extractor/suffix_table.hpp b/include/extractor/suffix_table.hpp index cadfb5e2e..53eb1062b 100644 --- a/include/extractor/suffix_table.hpp +++ b/include/extractor/suffix_table.hpp @@ -23,7 +23,7 @@ class SuffixTable final // check whether a string is part of the know suffix list bool isSuffix(const std::string &possible_suffix) const; - bool isSuffix(std::string_view possible_suffix) const; + bool isSuffix(std::string_view& possible_suffix) const; private: // Store lower-cased strings in SuffixTable and a set of StringViews for quick membership diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index 1ebf8a64a..a3dd72a06 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -27,8 +27,8 @@ namespace guidance // Name Change Logic // Used both during Extraction as well as during Post-Processing -inline std::string_view longest_common_substring(const std::string_view &lhs, - const std::string_view &rhs) +inline std::string_view longest_common_substring(const std::string_view lhs, + const std::string_view rhs) { if (lhs.empty() || rhs.empty()) return ""; @@ -131,8 +131,8 @@ inline bool requiresNameAnnounced(const StringView &from_name, const auto name_is_contained = boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name); - const auto checkForPrefixOrSuffixChange = [](const std::string_view &first, - const std::string_view &second, + const auto checkForPrefixOrSuffixChange = [](const std::string_view first, + const std::string_view second, const SuffixTable &suffix_table) { std::string first_prefix, first_suffix, second_prefix, second_suffix; std::tie(first_prefix, first_suffix, second_prefix, second_suffix) = @@ -203,7 +203,7 @@ inline bool requiresNameAnnounced(const std::string &from_name, struct NopSuffixTable final { NopSuffixTable() {} - bool isSuffix(const std::string_view &) const { return false; } + bool isSuffix(const std::string_view) const { return false; } } static const table; return requiresNameAnnounced(std::string_view(from_name), From 5dda33fa8884345b37f37ed77499e2d492993e4e Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 4 Nov 2022 11:42:37 +0100 Subject: [PATCH 12/23] More efficient toLower implementation --- include/util/guidance/name_announcements.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index a3dd72a06..02a62b119 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -70,7 +70,8 @@ template inline auto decompose(const StringView &lhs, cons const auto trim = [](StringView view) { // we compare suffixes based on this value, it might break UTF chars, but as long as we are // consistent in handling, we do not create bad results - std::string str(view); + std::string str; + str.reserve(view.size()); std::transform( str.begin(), str.end(), str.begin(), [](unsigned char c) { return std::tolower(c); }); auto front = str.find_first_not_of(' '); From 6fa7bd8abd3b239850cc0288c0f6abf14676dacc Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 4 Nov 2022 11:47:40 +0100 Subject: [PATCH 13/23] Upgrade check_tackinfo.py to Python3 --- scripts/check_taginfo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check_taginfo.py b/scripts/check_taginfo.py index 329335563..c71b46882 100755 --- a/scripts/check_taginfo.py +++ b/scripts/check_taginfo.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import json import sys @@ -7,7 +7,7 @@ import re WHITELIST = set(["mph"]) if len(sys.argv) < 3: - print "Not enough arguments.\nUsage: " + sys.argv[0] + " taginfo.json profile.lua" + print("Not enough arguments.\nUsage: " + sys.argv[0] + " taginfo.json profile.lua") sys.exit(1) taginfo_path = sys.argv[1] From a1c1fefd6e10af3b7223ad669c6b3bc452f4ca3d Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 4 Nov 2022 11:49:54 +0100 Subject: [PATCH 14/23] Fix formatting, pass by value --- include/extractor/suffix_table.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/extractor/suffix_table.hpp b/include/extractor/suffix_table.hpp index 53eb1062b..cadfb5e2e 100644 --- a/include/extractor/suffix_table.hpp +++ b/include/extractor/suffix_table.hpp @@ -23,7 +23,7 @@ class SuffixTable final // check whether a string is part of the know suffix list bool isSuffix(const std::string &possible_suffix) const; - bool isSuffix(std::string_view& possible_suffix) const; + bool isSuffix(std::string_view possible_suffix) const; private: // Store lower-cased strings in SuffixTable and a set of StringViews for quick membership From 6ab8728807650d3c6900c2c9d23f70bf90a2aeda Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sat, 5 Nov 2022 16:56:16 +0100 Subject: [PATCH 15/23] Apply workaround for Conan installation issue on CI (#6442) --- .github/workflows/osrm-backend.yml | 5 +++++ CHANGELOG.md | 1 + 2 files changed, 6 insertions(+) diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index 7d362ed26..442b64549 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -507,6 +507,11 @@ jobs: - name: Install dev dependencies run: | python3 -m pip install conan==1.53.0 + # workaround for issue that GitHub Actions seems to not adding it to PATH after https://github.com/actions/runner-images/pull/6499 + # and that's why CI cannot find conan executable installed above + if [[ "${RUNNER_OS}" == "macOS" ]]; then + echo "/Library/Frameworks/Python.framework/Versions/3.11/bin" >> $GITHUB_PATH + fi # ccache if [[ "${RUNNER_OS}" == "Linux" ]]; then diff --git a/CHANGELOG.md b/CHANGELOG.md index ce03e744a..028cb8c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - CHANGED: Update actions/cache to v3. [#6420](https://github.com/Project-OSRM/osrm-backend/pull/6420) - REMOVED: Drop support of Node 12 & 14. [#6431](https://github.com/Project-OSRM/osrm-backend/pull/6431) - Misc: + - FIXED: Apply workaround for Conan installation issue on CI. [#6442](https://github.com/Project-OSRM/osrm-backend/pull/6442) - FIXED: Fix `npm audit` warnings in NPM package. [#6437](https://github.com/Project-OSRM/osrm-backend/pull/6437) - FIXED: Handle snapping parameter for all plugins in NodeJs bindings, but not for Route only. [#6417](https://github.com/Project-OSRM/osrm-backend/pull/6417) - FIXED: Fix annotations=true handling in NodeJS bindings & libosrm. [#6415](https://github.com/Project-OSRM/osrm-backend/pull/6415/) From b13820f5203f01526e3d0460091170565f5dc60b Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 6 Nov 2022 12:19:32 +0100 Subject: [PATCH 16/23] Use std::back_inserter --- include/util/guidance/name_announcements.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index 02a62b119..db92f7fd9 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -73,7 +73,7 @@ template inline auto decompose(const StringView &lhs, cons std::string str; str.reserve(view.size()); std::transform( - str.begin(), str.end(), str.begin(), [](unsigned char c) { return std::tolower(c); }); + view.begin(), view.end(), std::back_inserter(str), [](unsigned char c) { return std::tolower(c); }); auto front = str.find_first_not_of(' '); if (front == std::string::npos) From bb4fd93fabf371db19c343824f72b5c5e3c0e205 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 6 Nov 2022 12:26:37 +0100 Subject: [PATCH 17/23] Fix formatting --- include/util/guidance/name_announcements.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index db92f7fd9..32202974d 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -72,8 +72,9 @@ template inline auto decompose(const StringView &lhs, cons // consistent in handling, we do not create bad results std::string str; str.reserve(view.size()); - std::transform( - view.begin(), view.end(), std::back_inserter(str), [](unsigned char c) { return std::tolower(c); }); + std::transform(view.begin(), view.end(), std::back_inserter(str), [](unsigned char c) { + return std::tolower(c); + }); auto front = str.find_first_not_of(' '); if (front == std::string::npos) From a12625afac3e3fb361ba49420a9e9f14dda1cd0e Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sun, 6 Nov 2022 13:33:10 +0100 Subject: [PATCH 18/23] Drop GCC7 support --- .github/workflows/osrm-backend.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index 442b64549..e4d233a22 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -264,15 +264,6 @@ jobs: CXXCOMPILER: g++-8 CXXFLAGS: -Wno-cast-function-type - - name: gcc-7-release - continue-on-error: false - node: 16 - runs-on: ubuntu-20.04 - BUILD_TOOLS: ON - BUILD_TYPE: Release - CCOMPILER: gcc-7 - CXXCOMPILER: g++-7 - - name: conan-macos-x64-release-node-16 build_node_package: true continue-on-error: false @@ -327,16 +318,6 @@ jobs: ENABLE_CONAN: ON ENABLE_APPLE_SILICON: ON - - name: gcc-7-release-shared - continue-on-error: false - node: 16 - runs-on: ubuntu-20.04 - BUILD_TOOLS: ON - BUILD_TYPE: Release - BUILD_SHARED_LIBS: ON - CCOMPILER: gcc-7 - CXXCOMPILER: g++-7 - - name: node-16-conan-linux-release build_node_package: true continue-on-error: false From 8a186e6f498b13d53d0764cbfb7ae7edc888d993 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sun, 6 Nov 2022 15:20:47 +0100 Subject: [PATCH 19/23] Remove C++14 references from README and package.json (#6438) --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d7bce257d..f4feae811 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![osrm-backend CI](https://github.com/Project-OSRM/osrm-backend/actions/workflows/osrm-backend.yml/badge.svg)](https://github.com/Project-OSRM/osrm-backend/actions/workflows/osrm-backend.yml) [![Codecov](https://codecov.io/gh/Project-OSRM/osrm-backend/branch/master/graph/badge.svg)](https://codecov.io/gh/Project-OSRM/osrm-backend) [![Discord](https://img.shields.io/discord/1034487840219860992)](https://discord.gg/es9CdcCXcb) -High performance routing engine written in C++14 designed to run on OpenStreetMap data. +High performance routing engine written in C++ designed to run on OpenStreetMap data. The following services are available via HTTP API, C++ library interface and NodeJs wrapper: - Nearest - Snaps coordinates to the street network and returns the nearest matches diff --git a/package.json b/package.json index 54b69e8c1..9124e8989 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@project-osrm/osrm", "version": "5.28.0-unreleased", "private": false, - "description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.", + "description": "The Open Source Routing Machine is a high performance routing engine written in C++ designed to run on OpenStreetMap data.", "dependencies": { "@mapbox/node-pre-gyp": "^1.0.10" }, From 5f82d0c9badfb63f9e920351193985d645b3af7a Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sun, 6 Nov 2022 21:13:04 +0100 Subject: [PATCH 20/23] Get rid of unused functions in util/json_util.hpp (#6446) --- CHANGELOG.md | 1 + include/util/container.hpp | 22 ---------------------- include/util/json_util.hpp | 25 ------------------------- 3 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 include/util/container.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index d7b462d2e..104145e68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - CHANGED: Update actions/cache to v3. [#6420](https://github.com/Project-OSRM/osrm-backend/pull/6420) - REMOVED: Drop support of Node 12 & 14. [#6431](https://github.com/Project-OSRM/osrm-backend/pull/6431) - Misc: + - REMOVED: Get rid of unused functions in util/json_util.hpp. [#6446](https://github.com/Project-OSRM/osrm-backend/pull/6446) - FIXED: Apply workaround for Conan installation issue on CI. [#6442](https://github.com/Project-OSRM/osrm-backend/pull/6442) - FIXED: Fix `npm audit` warnings in NPM package. [#6437](https://github.com/Project-OSRM/osrm-backend/pull/6437) - FIXED: Handle snapping parameter for all plugins in NodeJs bindings, but not for Route only. [#6417](https://github.com/Project-OSRM/osrm-backend/pull/6417) diff --git a/include/util/container.hpp b/include/util/container.hpp deleted file mode 100644 index 68ab7e526..000000000 --- a/include/util/container.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CONTAINER_HPP -#define CONTAINER_HPP - -#include - -namespace osrm -{ -namespace util -{ - -template void append_to_container(Container &&) {} - -template -void append_to_container(Container &&container, T value, Args &&... args) -{ - container.emplace_back(value); - append_to_container(std::forward(container), std::forward(args)...); -} -} // namespace util -} // namespace osrm - -#endif diff --git a/include/util/json_util.hpp b/include/util/json_util.hpp index 32a1bd7e4..311263d4e 100644 --- a/include/util/json_util.hpp +++ b/include/util/json_util.hpp @@ -2,7 +2,6 @@ #define JSON_UTIL_HPP #include "osrm/json_container.hpp" -#include "util/container.hpp" #include #include @@ -27,30 +26,6 @@ template T clamp_float(T d) return d; } - -template Array make_array(Args... args) -{ - Array a; - // TODO: check why a.values.emplace_back(args...); is not an option here - append_to_container(a.values, args...); - return a; -} - -// Easy acces to object hierachies -inline Value &get(Value &value) { return value; } - -template Value &get(Value &value, const char *key, Keys... keys) -{ - using recursive_object_t = mapbox::util::recursive_wrapper; - return get(value.get().get().values[key], keys...); -} - -template Value &get(Value &value, unsigned key, Keys... keys) -{ - using recursive_array_t = mapbox::util::recursive_wrapper; - return get(value.get().get().values[key], keys...); -} - } // namespace json } // namespace util } // namespace osrm From 2bbb347f572ba2778d5ed87d628e20936b6aa44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Rodrigo?= Date: Sun, 6 Nov 2022 21:27:03 +0100 Subject: [PATCH 21/23] Car profile, add new specific country speed limit at:urban, ca-on:rural and es:trunk (#6443) --- profiles/car.lua | 3 +++ taginfo.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/profiles/car.lua b/profiles/car.lua index 770805962..c832ffdb2 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -268,6 +268,7 @@ function setup() -- List only exceptions maxspeed_table = { + ["at:urban"] = 40, ["at:rural"] = 100, ["at:trunk"] = 100, ["be:motorway"] = 120, @@ -276,6 +277,7 @@ function setup() ["be-vlg:rural"] = 70, ["by:urban"] = 60, ["by:motorway"] = 110, + ["ca-on:rural"] = 80, ["ch:rural"] = 80, ["ch:trunk"] = 100, ["ch:motorway"] = 120, @@ -285,6 +287,7 @@ function setup() ["de:rural"] = 100, ["de:motorway"] = 0, ["dk:rural"] = 80, + ["es:trunk"] = 90, ["fr:rural"] = 80, ["gb:nsl_single"] = (60*1609)/1000, ["gb:nsl_dual"] = (70*1609)/1000, diff --git a/taginfo.json b/taginfo.json index 358845d80..27e911dbd 100644 --- a/taginfo.json +++ b/taginfo.json @@ -146,12 +146,14 @@ {"key": "maxspeed", "value": "rural"}, {"key": "maxspeed", "value": "trunk"}, {"key": "maxspeed", "value": "motorway"}, + {"key": "maxspeed", "value": "AT:urban"}, {"key": "maxspeed", "value": "AT:rural"}, {"key": "maxspeed", "value": "AT:trunk"}, {"key": "maxspeed", "value": "BE:motorway"}, {"key": "maxspeed", "value": "BE-VLG:rural"}, {"key": "maxspeed", "value": "BY:urban"}, {"key": "maxspeed", "value": "BY:motorway"}, + {"key": "maxspeed", "value": "CA-ON:rural"}, {"key": "maxspeed", "value": "CH:rural"}, {"key": "maxspeed", "value": "CH:trunk"}, {"key": "maxspeed", "value": "CH:motorway"}, @@ -161,6 +163,7 @@ {"key": "maxspeed", "value": "DE:rural"}, {"key": "maxspeed", "value": "DE:motorway"}, {"key": "maxspeed", "value": "DK:rural"}, + {"key": "maxspeed", "value": "ES:trunk"}, {"key": "maxspeed", "value": "FR:rural"}, {"key": "maxspeed", "value": "GB:nsl_single"}, {"key": "maxspeed", "value": "GB:nsl_dual"}, From 6d105234404bfdfa028a342d45f5bdb3f03c1934 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sun, 6 Nov 2022 22:45:35 +0100 Subject: [PATCH 22/23] Upgrade to clang-tidy 15 (#6439) --- .clang-tidy | 1 + .github/workflows/osrm-backend.yml | 16 +++++++++++----- CHANGELOG.md | 1 + src/contractor/graph_contractor.cpp | 2 -- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1c87f8702..03f7f39d2 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -42,6 +42,7 @@ Checks: > -llvm-twine-local, misc-*, -misc-argument-comment, + -misc-const-correctness, -misc-non-private-member-variables-in-classes, -misc-unconventional-assign-operator, -misc-no-recursion, diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index e4d233a22..4edcaf771 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -180,14 +180,14 @@ jobs: CXXCOMPILER: clang++-6.0 CUCUMBER_TIMEOUT: 60000 - - name: clang-11.0-debug-clang-tidy + - name: clang-15.0-debug-clang-tidy continue-on-error: false node: 16 runs-on: ubuntu-22.04 BUILD_TOOLS: ON BUILD_TYPE: Debug - CCOMPILER: clang-14 - CXXCOMPILER: clang++-14 + CCOMPILER: clang-15 + CXXCOMPILER: clang++-15 CUCUMBER_TIMEOUT: 60000 ENABLE_CLANG_TIDY: ON @@ -488,10 +488,11 @@ jobs: - name: Install dev dependencies run: | python3 -m pip install conan==1.53.0 + # workaround for issue that GitHub Actions seems to not adding it to PATH after https://github.com/actions/runner-images/pull/6499 # and that's why CI cannot find conan executable installed above if [[ "${RUNNER_OS}" == "macOS" ]]; then - echo "/Library/Frameworks/Python.framework/Versions/3.11/bin" >> $GITHUB_PATH + echo "/Library/Frameworks/Python.framework/Versions/Current/bin" >> $GITHUB_PATH fi # ccache @@ -504,6 +505,12 @@ jobs: # clang if [[ "${CCOMPILER}" == "clang-6.0" ]]; then sudo apt-get update -y && sudo apt-get install clang++-6 + elif [[ "${CCOMPILER}" == "clang-15" ]]; then + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-get update -y && sudo apt-get install software-properties-common + sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main' + sudo apt-get update -y && sudo apt-get install clang++-15 clang-tidy-15 + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 100000 fi # Linux dev packages @@ -532,7 +539,6 @@ jobs: tar zxvf onetbb.tgz sudo cp -a oneapi-tbb-${TBB_VERSION}/lib/. /usr/local/lib/ sudo cp -a oneapi-tbb-${TBB_VERSION}/include/. /usr/local/include/ - - name: Prepare build run: | mkdir ${OSRM_BUILD_DIR} diff --git a/CHANGELOG.md b/CHANGELOG.md index 104145e68..253cad5c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased - Changes from 5.27.1 - Build: + - CHANGED: Upgrade to clang-tidy 15. [#6439](https://github.com/Project-OSRM/osrm-backend/pull/6439) - CHANGED: Update actions/cache to v3. [#6420](https://github.com/Project-OSRM/osrm-backend/pull/6420) - REMOVED: Drop support of Node 12 & 14. [#6431](https://github.com/Project-OSRM/osrm-backend/pull/6431) - Misc: diff --git a/src/contractor/graph_contractor.cpp b/src/contractor/graph_contractor.cpp index 9fb4749d3..07628523d 100644 --- a/src/contractor/graph_contractor.cpp +++ b/src/contractor/graph_contractor.cpp @@ -645,7 +645,6 @@ std::vector contractGraph(ContractorGraph &graph, const util::XORFastHash<> hash; - unsigned current_level = 0; std::size_t next_renumbering = number_of_nodes * 0.35; while (remaining_nodes.size() > number_of_core_nodes) { @@ -761,7 +760,6 @@ std::vector contractGraph(ContractorGraph &graph, remaining_nodes.resize(begin_independent_nodes_idx); p.PrintStatus(number_of_contracted_nodes); - ++current_level; } node_data.Renumber(new_to_old_node_id); From a1b3efe2603d5c2c65fe2af56a87a7621dc02479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Rodrigo?= Date: Fri, 11 Nov 2022 21:52:54 +0100 Subject: [PATCH 23/23] Remove at:urban maxspeed, partial revert of 2bbb347f572ba2778d5ed87d628e20936b6aa44e (#6450) --- profiles/car.lua | 1 - taginfo.json | 1 - 2 files changed, 2 deletions(-) diff --git a/profiles/car.lua b/profiles/car.lua index c832ffdb2..95052d0ec 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -268,7 +268,6 @@ function setup() -- List only exceptions maxspeed_table = { - ["at:urban"] = 40, ["at:rural"] = 100, ["at:trunk"] = 100, ["be:motorway"] = 120, diff --git a/taginfo.json b/taginfo.json index 27e911dbd..85c57071a 100644 --- a/taginfo.json +++ b/taginfo.json @@ -146,7 +146,6 @@ {"key": "maxspeed", "value": "rural"}, {"key": "maxspeed", "value": "trunk"}, {"key": "maxspeed", "value": "motorway"}, - {"key": "maxspeed", "value": "AT:urban"}, {"key": "maxspeed", "value": "AT:rural"}, {"key": "maxspeed", "value": "AT:trunk"}, {"key": "maxspeed", "value": "BE:motorway"},