From: Mikko Rasa Date: Mon, 23 Feb 2015 14:41:02 +0000 (+0200) Subject: Use cached path length from occupied_tracks X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5b71cb905051d654c150cb0e098cade0cb502105;p=r2c2.git Use cached path length from occupied_tracks TrackType::get_path_length is not only a function call but also loops through all parts to calculate the length. --- diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index 97f1cf6..ad97cf7 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -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