Skip to content

Commit 0205cbc

Browse files
authored
Merge pull request #5561 from peoplestom/pessimistic_move
Removed un-needed calls to std::move
2 parents 71433c6 + 2889537 commit 0205cbc

File tree

10 files changed

+57
-49
lines changed

10 files changed

+57
-49
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ matrix:
121121
packages: ['libstdc++-4.9-dev']
122122
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON RUN_CLANG_FORMAT=ON ENABLE_LTO=ON
123123

124+
- os: linux
125+
compiler: "gcc-9-release"
126+
addons: &gcc9
127+
apt:
128+
sources: ['ubuntu-toolchain-r-test']
129+
packages: ['g++-9', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
130+
env: CCOMPILER='gcc-9' CXXCOMPILER='g++-9' BUILD_TYPE='Release' CXXFLAGS='-Wno-cast-function-type'
131+
124132
- os: linux
125133
compiler: "gcc-8-release"
126134
addons: &gcc8

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- Changes from 5.21.0
33
- Build:
44
- ADDED: optionally build Node `lts` and `latest` bindings [#5347](https://github.com/Project-OSRM/osrm-backend/pull/5347)
5+
- FIXED: pessimistic calls to std::move [#5560](https://github.com/Project-OSRM/osrm-backend/pull/5561)
56
- Features:
67
- ADDED: new waypoints parameter to the `route` plugin, enabling silent waypoints [#5345](https://github.com/Project-OSRM/osrm-backend/pull/5345)
78
- ADDED: data timestamp information in the response (saved in new file `.osrm.timestamp`). [#5115](https://github.com/Project-OSRM/osrm-backend/issues/5115)

include/engine/api/base_api.hpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <boost/assert.hpp>
1313
#include <boost/range/algorithm/transform.hpp>
1414

15+
#include <memory>
1516
#include <vector>
1617

1718
namespace osrm
@@ -73,7 +74,7 @@ class BaseAPI
7374
}
7475

7576
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
76-
MakeWaypoints(flatbuffers::FlatBufferBuilder &builder,
77+
MakeWaypoints(flatbuffers::FlatBufferBuilder *builder,
7778
const std::vector<PhantomNodes> &segment_end_coordinates) const
7879
{
7980
BOOST_ASSERT(parameters.coordinates.size() > 0);
@@ -82,43 +83,43 @@ class BaseAPI
8283
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
8384
waypoints.resize(parameters.coordinates.size());
8485
waypoints[0] =
85-
MakeWaypoint(builder, segment_end_coordinates.front().source_phantom).Finish();
86+
MakeWaypoint(builder, segment_end_coordinates.front().source_phantom)->Finish();
8687

8788
std::transform(segment_end_coordinates.begin(),
8889
segment_end_coordinates.end(),
8990
std::next(waypoints.begin()),
90-
[this, &builder](const PhantomNodes &phantom_pair) {
91-
return MakeWaypoint(builder, phantom_pair.target_phantom).Finish();
91+
[this, builder](const PhantomNodes &phantom_pair) {
92+
return MakeWaypoint(builder, phantom_pair.target_phantom)->Finish();
9293
});
93-
return builder.CreateVector(waypoints);
94+
return builder->CreateVector(waypoints);
9495
}
9596

9697
// FIXME: gcc 4.9 does not like MakeWaypoints to be protected
9798
// protected:
98-
fbresult::WaypointBuilder MakeWaypoint(flatbuffers::FlatBufferBuilder &builder,
99-
const PhantomNode &phantom) const
99+
std::unique_ptr<fbresult::WaypointBuilder> MakeWaypoint(flatbuffers::FlatBufferBuilder *builder,
100+
const PhantomNode &phantom) const
100101
{
101102

102103
auto location =
103104
fbresult::Position(static_cast<double>(util::toFloating(phantom.location.lon)),
104105
static_cast<double>(util::toFloating(phantom.location.lat)));
105-
auto name_string = builder.CreateString(
106+
auto name_string = builder->CreateString(
106107
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string());
107108

108109
boost::optional<flatbuffers::Offset<flatbuffers::String>> hint_string = boost::none;
109110
if (parameters.generate_hints)
110111
{
111-
hint_string = builder.CreateString(Hint{phantom, facade.GetCheckSum()}.ToBase64());
112+
hint_string = builder->CreateString(Hint{phantom, facade.GetCheckSum()}.ToBase64());
112113
}
113114

114-
fbresult::WaypointBuilder waypoint(builder);
115-
waypoint.add_location(&location);
116-
waypoint.add_distance(util::coordinate_calculation::fccApproximateDistance(
115+
auto waypoint = std::make_unique<fbresult::WaypointBuilder>(*builder);
116+
waypoint->add_location(&location);
117+
waypoint->add_distance(util::coordinate_calculation::fccApproximateDistance(
117118
phantom.location, phantom.input_location));
118-
waypoint.add_name(name_string);
119+
waypoint->add_name(name_string);
119120
if (hint_string)
120121
{
121-
waypoint.add_hint(*hint_string);
122+
waypoint->add_hint(*hint_string);
122123
}
123124
return waypoint;
124125
}

include/engine/api/match_api.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ class MatchAPI final : public RouteAPI
6262

6363
if (data_version_string)
6464
{
65-
response.add_data_version(*data_version_string);
65+
response->add_data_version(*data_version_string);
6666
}
6767

68-
fb_result.Finish(response.Finish());
68+
fb_result.Finish(response->Finish());
6969
}
7070
void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings,
7171
const std::vector<InternalRouteResult> &sub_routes,
@@ -141,29 +141,29 @@ class MatchAPI final : public RouteAPI
141141
}
142142
const auto &phantom =
143143
sub_matchings[matching_index.sub_matching_index].nodes[matching_index.point_index];
144-
auto waypoint = BaseAPI::MakeWaypoint(fb_result, phantom);
145-
waypoint.add_matchings_index(matching_index.sub_matching_index);
146-
waypoint.add_alternatives_count(sub_matchings[matching_index.sub_matching_index]
147-
.alternatives_count[matching_index.point_index]);
144+
auto waypoint = BaseAPI::MakeWaypoint(&fb_result, phantom);
145+
waypoint->add_matchings_index(matching_index.sub_matching_index);
146+
waypoint->add_alternatives_count(sub_matchings[matching_index.sub_matching_index]
147+
.alternatives_count[matching_index.point_index]);
148148
// waypoint indices need to be adjusted if route legs were collapsed
149149
// waypoint parameter assumes there is only one match object
150150
if (!parameters.waypoints.empty())
151151
{
152152
if (tidy_result.was_waypoint[trace_index])
153153
{
154-
waypoint.add_waypoint_index(was_waypoint_idx);
154+
waypoint->add_waypoint_index(was_waypoint_idx);
155155
was_waypoint_idx++;
156156
}
157157
else
158158
{
159-
waypoint.add_waypoint_index(0);
159+
waypoint->add_waypoint_index(0);
160160
}
161161
}
162162
else
163163
{
164-
waypoint.add_waypoint_index(matching_index.point_index);
164+
waypoint->add_waypoint_index(matching_index.point_index);
165165
}
166-
waypoints.push_back(waypoint.Finish());
166+
waypoints.push_back(waypoint->Finish());
167167
}
168168

169169
return fb_result.CreateVector(waypoints);

include/engine/api/nearest_api.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ class NearestAPI final : public BaseAPI
7171
auto node_values = MakeNodes(phantom_node);
7272
fbresult::Uint64Pair nodes{node_values.first, node_values.second};
7373

74-
auto waypoint = MakeWaypoint(fb_result, phantom_node);
75-
waypoint.add_nodes(&nodes);
76-
77-
return waypoint.Finish();
74+
auto waypoint = MakeWaypoint(&fb_result, phantom_node);
75+
waypoint->add_nodes(&nodes);
76+
return waypoint->Finish();
7877
});
7978

8079
waypoints_vector = fb_result.CreateVector(waypoints);

include/engine/api/route_api.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ class RouteAPI : public BaseAPI
8181

8282
auto response =
8383
MakeFBResponse(raw_routes, fb_result, [this, &all_start_end_points, &fb_result]() {
84-
return BaseAPI::MakeWaypoints(fb_result, all_start_end_points);
84+
return BaseAPI::MakeWaypoints(&fb_result, all_start_end_points);
8585
});
8686

8787
if (data_version_string)
8888
{
89-
response.add_data_version(*data_version_string);
89+
response->add_data_version(*data_version_string);
9090
}
91-
fb_result.Finish(response.Finish());
91+
fb_result.Finish(response->Finish());
9292
}
9393

9494
void
@@ -125,9 +125,10 @@ class RouteAPI : public BaseAPI
125125

126126
protected:
127127
template <typename GetWptsFn>
128-
fbresult::FBResultBuilder MakeFBResponse(const InternalManyRoutesResult &raw_routes,
129-
flatbuffers::FlatBufferBuilder &fb_result,
130-
GetWptsFn getWaypoints) const
128+
std::unique_ptr<fbresult::FBResultBuilder>
129+
MakeFBResponse(const InternalManyRoutesResult &raw_routes,
130+
flatbuffers::FlatBufferBuilder &fb_result,
131+
GetWptsFn getWaypoints) const
131132
{
132133

133134
std::vector<flatbuffers::Offset<fbresult::RouteObject>> routes;
@@ -151,9 +152,9 @@ class RouteAPI : public BaseAPI
151152
waypoints_vector = getWaypoints();
152153
}
153154

154-
fbresult::FBResultBuilder response(fb_result);
155-
response.add_routes(routes_vector);
156-
response.add_waypoints(waypoints_vector);
155+
auto response = std::make_unique<fbresult::FBResultBuilder>(fb_result);
156+
response->add_routes(routes_vector);
157+
response->add_waypoints(waypoints_vector);
157158

158159
return response;
159160
}
@@ -656,7 +657,6 @@ class RouteAPI : public BaseAPI
656657
step.intersections.end(),
657658
intersections.begin(),
658659
[&fb_result, this](const guidance::IntermediateIntersection &intersection) {
659-
660660
std::vector<flatbuffers::Offset<fbresult::Lane>> lanes;
661661
if (json::detail::hasValidLanes(intersection))
662662
{

include/engine/api/table_api.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class TableAPI final : public BaseAPI
236236

237237
boost::range::transform(
238238
phantoms, std::back_inserter(waypoints), [this, &builder](const PhantomNode &phantom) {
239-
return BaseAPI::MakeWaypoint(builder, phantom).Finish();
239+
return BaseAPI::MakeWaypoint(&builder, phantom)->Finish();
240240
});
241241
return builder.CreateVector(waypoints);
242242
}
@@ -252,7 +252,7 @@ class TableAPI final : public BaseAPI
252252
std::back_inserter(waypoints),
253253
[this, &builder, phantoms](const std::size_t idx) {
254254
BOOST_ASSERT(idx < phantoms.size());
255-
return BaseAPI::MakeWaypoint(builder, phantoms[idx]).Finish();
255+
return BaseAPI::MakeWaypoint(&builder, phantoms[idx])->Finish();
256256
});
257257
return builder.CreateVector(waypoints);
258258
}

include/engine/api/trip_api.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ class TripAPI final : public RouteAPI
6161

6262
if (data_version_string)
6363
{
64-
response.add_data_version(*data_version_string);
64+
response->add_data_version(*data_version_string);
6565
}
66-
fb_result.Finish(response.Finish());
66+
fb_result.Finish(response->Finish());
6767
}
6868
void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips,
6969
const std::vector<InternalRouteResult> &sub_routes,
@@ -127,10 +127,10 @@ class TripAPI final : public RouteAPI
127127
auto trip_index = input_idx_to_trip_idx[input_index];
128128
BOOST_ASSERT(!trip_index.NotUsed());
129129

130-
auto waypoint = BaseAPI::MakeWaypoint(fb_result, phantoms[input_index]);
131-
waypoint.add_waypoint_index(trip_index.point_index);
132-
waypoint.add_trips_index(trip_index.sub_trip_index);
133-
waypoints.push_back(waypoint.Finish());
130+
auto waypoint = BaseAPI::MakeWaypoint(&fb_result, phantoms[input_index]);
131+
waypoint->add_waypoint_index(trip_index.point_index);
132+
waypoint->add_trips_index(trip_index.sub_trip_index);
133+
waypoints.push_back(waypoint->Finish());
134134
}
135135

136136
return fb_result.CreateVector(waypoints);

include/updater/csv_file_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ template <typename Key, typename Value> struct CSVFilesParser
122122

123123
util::Log() << "Loaded " << filename << " with " << result.size() << "values";
124124

125-
return std::move(result);
125+
return result;
126126
}
127127
catch (const boost::exception &e)
128128
{

src/server/api/parameters_parser.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ boost::optional<ParameterT> parseParameters(std::string::iterator &iter,
4545
const auto ok =
4646
boost::spirit::qi::parse(iter, end, grammar(boost::phoenix::ref(parameters)));
4747

48-
// return move(a.b) is needed to move b out of a and then return the rvalue by implicit move
4948
if (ok && iter == end)
50-
return std::move(parameters);
49+
return parameters;
5150
}
5251
catch (const qi::expectation_failure<It> &failure)
5352
{

0 commit comments

Comments
 (0)