From: Mikko Rasa Date: Fri, 20 Feb 2015 15:41:53 +0000 (+0200) Subject: Store zone blocks in order and use add_tracks to load them X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1e6ae9272462ae82093a572f34494b265db7b1a3;p=r2c2.git Store zone blocks in order and use add_tracks to load them --- diff --git a/source/libr2c2/zone.cpp b/source/libr2c2/zone.cpp index 30b60e9..8b6c95f 100644 --- a/source/libr2c2/zone.cpp +++ b/source/libr2c2/zone.cpp @@ -62,12 +62,19 @@ void Zone::save(list &st) const if(number) st.push_back((DataFile::Statement("number"), number)); - set block_ids; - for(TrackSet::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) - block_ids.insert((*i)->get_block().get_id()); - - for(set::const_iterator i=block_ids.begin(); i!=block_ids.end(); ++i) - st.push_back((DataFile::Statement("block"), *i)); + unsigned last_block = 0; + TrackIter iter = ends[0].reverse(); + while(iter && tracks.count(iter.track())) + { + unsigned block_id = iter->get_block().get_id(); + if(block_id!=last_block) + { + st.push_back((DataFile::Statement("block"), block_id)); + last_block = block_id; + } + + iter = next_iter(iter); + } } DataFile::Statement Zone::save_reference() const @@ -93,8 +100,7 @@ void Zone::Loader::finish() void Zone::Loader::block(unsigned b) { Block &blk = obj.layout.get_block(b); - const set &btracks = blk.get_tracks(); - obj.tracks.insert(btracks.begin(), btracks.end()); + obj.add_tracks(blk.get_tracks()); } } // namespace R2C2