From ada37f44b9c44d726ecc3467ecdfdeb1c4137e44 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 26 May 2013 01:54:24 +0300 Subject: [PATCH] Refactor TrackIter::block_iter The new implementation is slightly more efficient in certain cases and won't choke at the end of a line. --- source/libr2c2/trackiter.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/source/libr2c2/trackiter.cpp b/source/libr2c2/trackiter.cpp index c3bb7d4..31ebf08 100644 --- a/source/libr2c2/trackiter.cpp +++ b/source/libr2c2/trackiter.cpp @@ -30,27 +30,29 @@ BlockIter TrackIter::block_iter() const Block &block = _track->get_block(); const vector &beps = block.get_endpoints(); - if(_track->get_type().is_turnout()) - { - /* A turnouts is the only track in its block. Go ahead and find the - matching endpoint in the block. */ - for(unsigned i=0; iget_type().is_turnout()) { TrackIter rev = reverse(); + TrackIter last; while(rev && &rev.track()->get_block()==&block) { - TrackIter fwd = rev.reverse(); - - for(unsigned i=0; i