Skip to content

Commit 201fd22

Browse files
committed
Roll requiredSectors into readerwriter.cc.
1 parent d0fb85e commit 201fd22

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

lib/decoders/decoders.cc

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ std::unique_ptr<Decoder> Decoder::create(const DecoderProto& config)
6161
}
6262

6363
std::shared_ptr<TrackDataFlux> Decoder::decodeToSectors(
64-
std::shared_ptr<const Fluxmap> fluxmap, std::shared_ptr<const TrackInfo>& trackInfo)
64+
std::shared_ptr<const Fluxmap> fluxmap,
65+
std::shared_ptr<const TrackInfo>& trackInfo)
6566
{
6667
_trackdata = std::make_shared<TrackDataFlux>();
6768
_trackdata->fluxmap = fluxmap;
@@ -220,16 +221,3 @@ uint64_t Decoder::readRaw64()
220221
{
221222
return toBytes(readRawBits(64)).reader().read_be64();
222223
}
223-
224-
std::set<LogicalLocation> Decoder::requiredSectors(
225-
std::shared_ptr<const TrackInfo>& trackInfo) const
226-
{
227-
const auto trackLayout =
228-
Layout::getLayoutOfTrackPhysical(trackInfo->physicalTrack, trackInfo->physicalSide);
229-
230-
std::set<LogicalLocation> results;
231-
for (unsigned sectorId : trackLayout->logicalSectorOrder)
232-
results.insert(LogicalLocation{
233-
trackLayout->logicalTrack, trackLayout->logicalSide, sectorId});
234-
return results;
235-
}

lib/decoders/decoders.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ class Decoder
8989
return _fmr->getDuration();
9090
}
9191

92-
virtual std::set<LogicalLocation> requiredSectors(
93-
std::shared_ptr<const TrackInfo>& trackInfo) const;
94-
9592
protected:
9693
virtual void beginTrack(){};
9794
virtual nanoseconds_t advanceToNextRecord() = 0;

lib/readerwriter.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,29 @@ static std::set<std::shared_ptr<const Sector>> collectSectors(
156156

157157
BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux,
158158
Decoder& decoder,
159-
std::shared_ptr<const TrackInfo>& layout)
159+
std::shared_ptr<const TrackInfo>& trackLayout)
160160
{
161161
std::set<std::shared_ptr<const Sector>> track_sectors;
162162

163+
/* Add the sectors which were there. */
164+
163165
for (auto& trackdataflux : trackFlux.trackDatas)
164166
track_sectors.insert(
165167
trackdataflux->sectors.begin(), trackdataflux->sectors.end());
166168

167-
for (auto& logicalLocation : decoder.requiredSectors(trackFlux.trackInfo))
169+
/* Add the sectors which should be there. */
170+
171+
for (unsigned sectorId : trackLayout->logicalSectorOrder)
168172
{
169-
auto sector = std::make_shared<Sector>(logicalLocation);
173+
auto sector = std::make_shared<Sector>(LogicalLocation{
174+
trackLayout->logicalTrack, trackLayout->logicalSide, sectorId});
175+
170176
sector->status = Sector::MISSING;
171177
track_sectors.insert(sector);
172178
}
173179

180+
/* Deduplicate. */
181+
174182
trackFlux.sectors = collectSectors(track_sectors);
175183
if (trackFlux.sectors.empty())
176184
return HAS_BAD_SECTORS;
@@ -402,7 +410,7 @@ void writeDiskCommand(const Image& image,
402410

403411
void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink)
404412
{
405-
auto locations = Layout::computeLocations();
413+
auto locations = Layout::computeLocations();
406414
writeTracks(
407415
fluxSink,
408416
[&](std::shared_ptr<const TrackInfo>& layout)

0 commit comments

Comments
 (0)