]> git.tdb.fi Git - r2c2.git/commitdiff
Use cached path length from occupied_tracks
authorMikko Rasa <tdb@tdb.fi>
Mon, 23 Feb 2015 14:41:02 +0000 (16:41 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 23 Feb 2015 14:41:02 +0000 (16:41 +0200)
TrackType::get_path_length is not only a function call but also loops
through all parts to calculate the length.

source/libr2c2/trainrouteplanner.cpp

index 97f1cf6c8501af801a42b2123768503c929e7b14..ad97cf79f77c0255f23b9c1be7ed5cf0cfe58e69 100644 (file)
@@ -363,7 +363,7 @@ TrainRoutePlanner::TrainRoutingState::~TrainRoutingState()
 
 Time::TimeDelta TrainRoutePlanner::TrainRoutingState::get_time_to_next_track() const
 {
-       return ((track->get_type().get_path_length(path)-offset)/info->speed)*Time::sec+delay;
+       return ((occupied_tracks->path_length-offset)/info->speed)*Time::sec+delay;
 }
 
 Time::TimeDelta TrainRoutePlanner::TrainRoutingState::get_time_to_pass(Track &trk) const
@@ -520,7 +520,7 @@ void TrainRoutePlanner::TrainRoutingState::update_estimate()
        TrackIter iter = track.reverse(path);
        remaining_estimate = info->metrics[waypoint]->get_distance_from(*iter.track(), iter.entry());
        if(remaining_estimate>=0)
-               remaining_estimate += track->get_type().get_path_length(path)-offset;
+               remaining_estimate += occupied_tracks->path_length-offset;
 }
 
 bool TrainRoutePlanner::TrainRoutingState::is_viable() const