Fix performance issues after migration to sol2 3.3.0

This commit is contained in:
Siarhei Fedartsou 2022-08-09 20:27:58 +02:00
parent 00816722dd
commit 2fda5b3057
2 changed files with 12 additions and 8 deletions

View File

@ -93,6 +93,10 @@ class ExtractionRelationContainer
using RelationIDList = std::vector<ExtractionRelation::OsmIDTyped>; using RelationIDList = std::vector<ExtractionRelation::OsmIDTyped>;
using RelationRefMap = std::unordered_map<std::uint64_t, RelationIDList>; using RelationRefMap = std::unordered_map<std::uint64_t, RelationIDList>;
ExtractionRelationContainer() = default;
ExtractionRelationContainer(ExtractionRelationContainer&&) = default;
ExtractionRelationContainer(const ExtractionRelationContainer&) = delete;
void AddRelation(ExtractionRelation &&rel) void AddRelation(ExtractionRelation &&rel)
{ {
rel.Prepare(); rel.Prepare();

View File

@ -1093,7 +1093,7 @@ void Sol2ScriptingEnvironment::ProcessTurn(ExtractionTurn &turn)
case 2: case 2:
if (context.has_turn_penalty_function) if (context.has_turn_penalty_function)
{ {
context.turn_function(context.profile_table, turn); context.turn_function(context.profile_table, std::ref(turn));
// Turn weight falls back to the duration value in deciseconds // Turn weight falls back to the duration value in deciseconds
// or uses the extracted unit-less weight value // or uses the extracted unit-less weight value
@ -1108,7 +1108,7 @@ void Sol2ScriptingEnvironment::ProcessTurn(ExtractionTurn &turn)
case 1: case 1:
if (context.has_turn_penalty_function) if (context.has_turn_penalty_function)
{ {
context.turn_function(turn); context.turn_function(std::ref(turn));
// Turn weight falls back to the duration value in deciseconds // Turn weight falls back to the duration value in deciseconds
// or uses the extracted unit-less weight value // or uses the extracted unit-less weight value
@ -1159,14 +1159,14 @@ void Sol2ScriptingEnvironment::ProcessSegment(ExtractionSegment &segment)
case 4: case 4:
case 3: case 3:
case 2: case 2:
context.segment_function(context.profile_table, segment); context.segment_function(context.profile_table, std::ref(segment));
break; break;
case 1: case 1:
context.segment_function(segment); context.segment_function( std::ref(segment));
break; break;
case 0: case 0:
context.segment_function( context.segment_function(
segment.source, segment.target, segment.distance, segment.duration); std::ref(segment.source), std::ref(segment.target), segment.distance, segment.duration);
segment.weight = segment.duration; // back-compatibility fallback to duration segment.weight = segment.duration; // back-compatibility fallback to duration
break; break;
} }
@ -1183,14 +1183,14 @@ void LuaScriptingContext::ProcessNode(const osmium::Node &node,
{ {
case 4: case 4:
case 3: case 3:
node_function(profile_table, std::cref(node), result, relations); node_function(profile_table, std::cref(node), std::ref(result), std::cref(relations));
break; break;
case 2: case 2:
node_function(profile_table, std::cref(node), result); node_function(profile_table, std::cref(node), std::ref(result));
break; break;
case 1: case 1:
case 0: case 0:
node_function(std::cref(node), result); node_function(std::cref(node), std::ref(result));
break; break;
} }
} }