Skip to content

Commit 84845ff

Browse files
TheMarexPatrick Niklaus
authored andcommitted
Replace optional<EdgeWeight> with constant value
1 parent f65958f commit 84845ff

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

include/extractor/compressed_edge_container.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <string>
1111
#include <vector>
1212

13-
#include <boost/optional.hpp>
14-
1513
namespace osrm
1614
{
1715
namespace extractor
@@ -41,8 +39,8 @@ class CompressedEdgeContainer
4139
const EdgeDuration duration2,
4240
// node-penalties can be added before/or after the traversal of an edge which
4341
// depends on whether we traverse the link forwards or backwards.
44-
const boost::optional<EdgeWeight> node_weight_penalty = boost::none,
45-
const boost::optional<EdgeDuration> node_duration_penalty = boost::none);
42+
const EdgeWeight node_weight_penalty = INVALID_EDGE_WEIGHT,
43+
const EdgeDuration node_duration_penalty = MAXIMAL_EDGE_DURATION);
4644

4745
void AddUncompressedEdge(const EdgeID edge_id,
4846
const NodeID target_node,

src/extractor/compressed_edge_container.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ void CompressedEdgeContainer::CompressEdge(
112112
const EdgeWeight weight2,
113113
const EdgeDuration duration1,
114114
const EdgeDuration duration2,
115-
const boost::optional<EdgeWeight> node_weight_penalty,
116-
const boost::optional<EdgeDuration> node_duration_penalty)
115+
const EdgeWeight node_weight_penalty,
116+
const EdgeDuration node_duration_penalty)
117117
{
118118
// remove super-trivial geometries
119119
BOOST_ASSERT(SPECIAL_EDGEID != edge_id_1);
@@ -169,10 +169,10 @@ void CompressedEdgeContainer::CompressEdge(
169169

170170
// if the via-node offers a penalty, we add the weight of the penalty as an artificial
171171
// segment that references SPECIAL_NODEID
172-
if (node_weight_penalty && node_duration_penalty)
172+
if (node_weight_penalty != INVALID_EDGE_WEIGHT && node_duration_penalty != MAXIMAL_EDGE_DURATION)
173173
{
174174
edge_bucket_list1.emplace_back(OnewayCompressedEdge{
175-
via_node_id, ClipWeight(*node_weight_penalty), ClipDuration(*node_duration_penalty)});
175+
via_node_id, ClipWeight(node_weight_penalty), ClipDuration(node_duration_penalty)});
176176
}
177177

178178
if (HasEntryForID(edge_id_2))

src/extractor/graph_compressor.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ void GraphCompressor::Compress(
211211
// doesn't have access to.
212212
*/
213213
const bool has_node_penalty = traffic_signals.find(node_v) != traffic_signals.end();
214-
boost::optional<EdgeDuration> node_duration_penalty = boost::none;
215-
boost::optional<EdgeWeight> node_weight_penalty = boost::none;
214+
EdgeDuration node_duration_penalty = MAXIMAL_EDGE_DURATION;
215+
EdgeWeight node_weight_penalty = INVALID_EDGE_WEIGHT;
216216
if (has_node_penalty)
217217
{
218218
// we cannot handle this as node penalty, if it depends on turn direction
@@ -277,12 +277,12 @@ void GraphCompressor::Compress(
277277
graph.GetEdgeData(forward_e1).duration += forward_duration2;
278278
graph.GetEdgeData(reverse_e1).duration += reverse_duration2;
279279

280-
if (node_weight_penalty && node_duration_penalty)
280+
if (node_weight_penalty != INVALID_EDGE_WEIGHT && node_duration_penalty != MAXIMAL_EDGE_DURATION)
281281
{
282-
graph.GetEdgeData(forward_e1).weight += *node_weight_penalty;
283-
graph.GetEdgeData(reverse_e1).weight += *node_weight_penalty;
284-
graph.GetEdgeData(forward_e1).duration += *node_duration_penalty;
285-
graph.GetEdgeData(reverse_e1).duration += *node_duration_penalty;
282+
graph.GetEdgeData(forward_e1).weight += node_weight_penalty;
283+
graph.GetEdgeData(reverse_e1).weight += node_weight_penalty;
284+
graph.GetEdgeData(forward_e1).duration += node_duration_penalty;
285+
graph.GetEdgeData(reverse_e1).duration += node_duration_penalty;
286286
}
287287

288288
// extend e1's to targets of e2's

0 commit comments

Comments
 (0)