Implements Zero-Copy String Views onto Contiguous Memory, resolves #3265.

- http://www.boost.org/doc/libs/1_61_0/libs/utility/doc/html/string_ref.html
- http://en.cppreference.com/w/cpp/string/basic_string_view
This commit is contained in:
Daniel J. Hofmann
2016-12-15 18:27:09 +01:00
parent b1f1c26703
commit c277b95f03
13 changed files with 219 additions and 144 deletions
+2 -2
View File
@@ -186,11 +186,11 @@ inline RouteLeg assembleLeg(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;
return name.to_string();
else
{
const auto ref = facade.GetRefForID(name_id);
return ref;
return ref.to_string();
}
};
+16 -16
View File
@@ -105,10 +105,10 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
const auto distance = leg_geometry.segment_distances[segment_index];
steps.push_back(RouteStep{step_name_id,
std::move(name),
std::move(ref),
std::move(pronunciation),
std::move(destinations),
name.to_string(),
ref.to_string(),
pronunciation.to_string(),
destinations.to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
segment_duration / 10.0,
@@ -179,10 +179,10 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
const int duration = segment_duration + target_duration;
BOOST_ASSERT(duration >= 0);
steps.push_back(RouteStep{step_name_id,
facade.GetNameForID(step_name_id),
facade.GetRefForID(step_name_id),
facade.GetPronunciationForID(step_name_id),
facade.GetDestinationsForID(step_name_id),
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(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
@@ -206,10 +206,10 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
BOOST_ASSERT(duration >= 0);
steps.push_back(RouteStep{source_node.name_id,
facade.GetNameForID(source_node.name_id),
facade.GetRefForID(source_node.name_id),
facade.GetPronunciationForID(source_node.name_id),
facade.GetDestinationsForID(source_node.name_id),
facade.GetNameForID(source_node.name_id).to_string(),
facade.GetRefForID(source_node.name_id).to_string(),
facade.GetPronunciationForID(source_node.name_id).to_string(),
facade.GetDestinationsForID(source_node.name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
@@ -243,10 +243,10 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
BOOST_ASSERT(!leg_geometry.locations.empty());
steps.push_back(RouteStep{target_node.name_id,
facade.GetNameForID(target_node.name_id),
facade.GetRefForID(target_node.name_id),
facade.GetPronunciationForID(target_node.name_id),
facade.GetDestinationsForID(target_node.name_id),
facade.GetNameForID(target_node.name_id).to_string(),
facade.GetRefForID(target_node.name_id).to_string(),
facade.GetPronunciationForID(target_node.name_id).to_string(),
facade.GetDestinationsForID(target_node.name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
ZERO_DURATION,