Avoid a number of temporaries
This commit is contained in:
parent
0b139ff05d
commit
ee178b2d3a
@ -105,7 +105,7 @@ std::vector<CellMetric> customizeFilteredMetrics(const partitioner::MultiLevelEd
|
|||||||
{
|
{
|
||||||
std::vector<CellMetric> metrics;
|
std::vector<CellMetric> metrics;
|
||||||
|
|
||||||
for (auto filter : node_filters)
|
for (const auto& filter : node_filters)
|
||||||
{
|
{
|
||||||
auto metric = storage.MakeMetric();
|
auto metric = storage.MakeMetric();
|
||||||
customizer.Customize(graph, storage, filter, metric);
|
customizer.Customize(graph, storage, filter, metric);
|
||||||
|
|||||||
@ -242,7 +242,7 @@ util::json::Object makeWaypoint(const util::Coordinate &location,
|
|||||||
std::string name,
|
std::string name,
|
||||||
const Hint &hint)
|
const Hint &hint)
|
||||||
{
|
{
|
||||||
auto waypoint = makeWaypoint(location, distance, name);
|
auto waypoint = makeWaypoint(location, distance, std::move(name));
|
||||||
waypoint.values["hint"] = hint.ToBase64();
|
waypoint.values["hint"] = hint.ToBase64();
|
||||||
return waypoint;
|
return waypoint;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -509,7 +509,7 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
|
|||||||
|
|
||||||
// OSM elements Lua parser
|
// OSM elements Lua parser
|
||||||
tbb::filter_t<SharedBuffer, ParsedBuffer> buffer_transformer(
|
tbb::filter_t<SharedBuffer, ParsedBuffer> buffer_transformer(
|
||||||
tbb::filter::parallel, [&](const SharedBuffer buffer) {
|
tbb::filter::parallel, [&](const SharedBuffer& buffer) {
|
||||||
|
|
||||||
ParsedBuffer parsed_buffer;
|
ParsedBuffer parsed_buffer;
|
||||||
parsed_buffer.buffer = buffer;
|
parsed_buffer.buffer = buffer;
|
||||||
@ -559,7 +559,7 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
|
|||||||
});
|
});
|
||||||
|
|
||||||
tbb::filter_t<SharedBuffer, std::shared_ptr<ExtractionRelationContainer>> buffer_relation_cache(
|
tbb::filter_t<SharedBuffer, std::shared_ptr<ExtractionRelationContainer>> buffer_relation_cache(
|
||||||
tbb::filter::parallel, [&](const SharedBuffer buffer) {
|
tbb::filter::parallel, [&](const SharedBuffer& buffer) {
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return std::shared_ptr<ExtractionRelationContainer>{};
|
return std::shared_ptr<ExtractionRelationContainer>{};
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
|
|||||||
unsigned number_of_relations = 0;
|
unsigned number_of_relations = 0;
|
||||||
tbb::filter_t<std::shared_ptr<ExtractionRelationContainer>, void> buffer_storage_relation(
|
tbb::filter_t<std::shared_ptr<ExtractionRelationContainer>, void> buffer_storage_relation(
|
||||||
tbb::filter::serial_in_order,
|
tbb::filter::serial_in_order,
|
||||||
[&](const std::shared_ptr<ExtractionRelationContainer> parsed_relations) {
|
[&](const std::shared_ptr<ExtractionRelationContainer> &parsed_relations) {
|
||||||
|
|
||||||
number_of_relations += parsed_relations->GetRelationsNum();
|
number_of_relations += parsed_relations->GetRelationsNum();
|
||||||
relations.Merge(std::move(*parsed_relations));
|
relations.Merge(std::move(*parsed_relations));
|
||||||
|
|||||||
@ -109,8 +109,8 @@ std::unordered_set<EdgeID> findSegregatedNodes(const extractor::NodeBasedGraphFa
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto isSegregated = [&](NodeID node1,
|
auto isSegregated = [&](NodeID node1,
|
||||||
std::vector<EdgeInfo> v1,
|
const std::vector<EdgeInfo> &v1,
|
||||||
std::vector<EdgeInfo> v2,
|
const std::vector<EdgeInfo> &v2,
|
||||||
EdgeInfo const ¤t,
|
EdgeInfo const ¤t,
|
||||||
double edge_length) {
|
double edge_length) {
|
||||||
// Internal intersection edges must be short and cannot be a roundabout.
|
// Internal intersection edges must be short and cannot be a roundabout.
|
||||||
|
|||||||
@ -64,7 +64,7 @@ bool TurnLaneData::operator<(const TurnLaneData &other) const
|
|||||||
std::find(tag_by_modifier, tag_by_modifier + 8, other.tag);
|
std::find(tag_by_modifier, tag_by_modifier + 8, other.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
LaneDataVector laneDataFromDescription(TurnLaneDescription turn_lane_description)
|
LaneDataVector laneDataFromDescription(const TurnLaneDescription& turn_lane_description)
|
||||||
{
|
{
|
||||||
typedef std::unordered_map<TurnLaneType::Mask, std::pair<LaneID, LaneID>> LaneMap;
|
typedef std::unordered_map<TurnLaneType::Mask, std::pair<LaneID, LaneID>> LaneMap;
|
||||||
// TODO need to handle cases that have none-in between two identical values
|
// TODO need to handle cases that have none-in between two identical values
|
||||||
|
|||||||
@ -507,7 +507,7 @@ bool IsRestrictionValid(const Timezoner &tz_handler, const extractor::Conditiona
|
|||||||
std::vector<std::uint64_t>
|
std::vector<std::uint64_t>
|
||||||
updateConditionalTurns(std::vector<TurnPenalty> &turn_weight_penalties,
|
updateConditionalTurns(std::vector<TurnPenalty> &turn_weight_penalties,
|
||||||
const std::vector<extractor::ConditionalTurnPenalty> &conditional_turns,
|
const std::vector<extractor::ConditionalTurnPenalty> &conditional_turns,
|
||||||
Timezoner time_zone_handler)
|
const Timezoner& time_zone_handler)
|
||||||
{
|
{
|
||||||
std::vector<std::uint64_t> updated_turns;
|
std::vector<std::uint64_t> updated_turns;
|
||||||
if (conditional_turns.size() == 0)
|
if (conditional_turns.size() == 0)
|
||||||
|
|||||||
@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(incorrect_polylines)
|
|||||||
};
|
};
|
||||||
util::Coordinate coord{util::FloatLongitude{0}, util::FloatLatitude{0}};
|
util::Coordinate coord{util::FloatLongitude{0}, util::FloatLatitude{0}};
|
||||||
|
|
||||||
for (auto polyline : polylines)
|
for (const auto& polyline : polylines)
|
||||||
{
|
{
|
||||||
const auto result = decodePolyline(polyline);
|
const auto result = decodePolyline(polyline);
|
||||||
BOOST_CHECK(result.size() == 1);
|
BOOST_CHECK(result.size() == 1);
|
||||||
|
|||||||
@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(test_json_linestring)
|
|||||||
const auto coords = geom.values["coordinates"].get<util::json::Array>().values;
|
const auto coords = geom.values["coordinates"].get<util::json::Array>().values;
|
||||||
BOOST_CHECK_EQUAL(coords.size(), 3); // array of three location arrays
|
BOOST_CHECK_EQUAL(coords.size(), 3); // array of three location arrays
|
||||||
|
|
||||||
for (const auto each : coords)
|
for (const auto& each : coords)
|
||||||
{
|
{
|
||||||
const auto loc = each.get<util::json::Array>().values;
|
const auto loc = each.get<util::json::Array>().values;
|
||||||
BOOST_CHECK_EQUAL(loc.size(), 2);
|
BOOST_CHECK_EQUAL(loc.size(), 2);
|
||||||
@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(test_json_linestring)
|
|||||||
|
|
||||||
(void)lon;
|
(void)lon;
|
||||||
(void)lat;
|
(void)lat;
|
||||||
// cast fails if type do not match
|
// cast fails if types do not match
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(test_json_single_point)
|
|||||||
const auto coords = geom.values["coordinates"].get<util::json::Array>().values;
|
const auto coords = geom.values["coordinates"].get<util::json::Array>().values;
|
||||||
BOOST_CHECK_EQUAL(coords.size(), 2); // array of two location arrays
|
BOOST_CHECK_EQUAL(coords.size(), 2); // array of two location arrays
|
||||||
|
|
||||||
for (const auto each : coords)
|
for (const auto& each : coords)
|
||||||
{
|
{
|
||||||
const auto loc = each.get<util::json::Array>().values;
|
const auto loc = each.get<util::json::Array>().values;
|
||||||
BOOST_CHECK_EQUAL(loc.size(), 2);
|
BOOST_CHECK_EQUAL(loc.size(), 2);
|
||||||
@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(test_json_single_point)
|
|||||||
|
|
||||||
(void)lon;
|
(void)lon;
|
||||||
(void)lat;
|
(void)lat;
|
||||||
// cast fails if type do not match
|
// cast fails if types do not match
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
|
|||||||
const auto &entries = intersection_object.at("entry").get<json::Array>().values;
|
const auto &entries = intersection_object.at("entry").get<json::Array>().values;
|
||||||
BOOST_CHECK(bearings.size() == entries.size());
|
BOOST_CHECK(bearings.size() == entries.size());
|
||||||
|
|
||||||
for (const auto bearing : bearings)
|
for (const auto& bearing : bearings)
|
||||||
BOOST_CHECK(0. <= bearing.get<json::Number>().value &&
|
BOOST_CHECK(0. <= bearing.get<json::Number>().value &&
|
||||||
bearing.get<json::Number>().value <= 360.);
|
bearing.get<json::Number>().value <= 360.);
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(dividing_four_grid_cells)
|
|||||||
|
|
||||||
RecursiveBisection bisection(graph, 120, 1.1, 0.25, 10, 1);
|
RecursiveBisection bisection(graph, 120, 1.1, 0.25, 10, 1);
|
||||||
|
|
||||||
const auto result = bisection.BisectionIDs();
|
const auto& result = bisection.BisectionIDs();
|
||||||
// all same IDs withing a group
|
// all same IDs withing a group
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
for (int j = 0; j < rows * cols; ++j)
|
for (int j = 0; j < rows * cols; ++j)
|
||||||
|
|||||||
@ -15,7 +15,7 @@ using namespace osrm::util;
|
|||||||
constexpr unsigned BLOCK_SIZE = 16;
|
constexpr unsigned BLOCK_SIZE = 16;
|
||||||
typedef RangeTable<BLOCK_SIZE, osrm::storage::Ownership::Container> TestRangeTable;
|
typedef RangeTable<BLOCK_SIZE, osrm::storage::Ownership::Container> TestRangeTable;
|
||||||
|
|
||||||
void ConstructionTest(std::vector<unsigned> lengths, std::vector<unsigned> offsets)
|
void ConstructionTest(const std::vector<unsigned>& lengths, const std::vector<unsigned>& offsets)
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL(lengths.size(), offsets.size() - 1);
|
BOOST_CHECK_EQUAL(lengths.size(), offsets.size() - 1);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user