diff --git a/Analyser/Static/AmstradCPC/StaticAnalyser.cpp b/Analyser/Static/AmstradCPC/StaticAnalyser.cpp index cc7ed4ecf..f302ab3ee 100644 --- a/Analyser/Static/AmstradCPC/StaticAnalyser.cpp +++ b/Analyser/Static/AmstradCPC/StaticAnalyser.cpp @@ -64,14 +64,14 @@ static void InspectCatalogue( std::vector candidate_files; candidate_files.reserve(catalogue.files.size()); - for(auto &file : catalogue.files) { + for(const auto &file : catalogue.files) { candidate_files.push_back(&file); } // Remove all files with untypable characters. candidate_files.erase( std::remove_if(candidate_files.begin(), candidate_files.end(), [](const Storage::Disk::CPM::File *file) { - for(auto c : file->name + file->type) { + for(const auto c : file->name + file->type) { if(c < 32) return true; } return false; @@ -80,7 +80,7 @@ static void InspectCatalogue( // If that leaves a mix of 'system' (i.e. hidden) and non-system files, remove the system files. bool are_all_system = true; - for(auto file : candidate_files) { + for(const auto &file : candidate_files) { if(!file->system) { are_all_system = false; break; @@ -137,13 +137,13 @@ static void InspectCatalogue( std::map name_counts; std::map indices_by_name; std::size_t index = 0; - for(auto file : candidate_files) { + for(const auto &file : candidate_files) { name_counts[file->name]++; indices_by_name[file->name] = index; index++; } if(name_counts.size() == 2) { - for(auto &pair : name_counts) { + for(const auto &pair : name_counts) { if(pair.second == 1) { target->loading_command = RunCommandFor(*candidate_files[indices_by_name[pair.first]]); return; @@ -214,7 +214,7 @@ Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(const Medi system_format.catalogue_allocation_bitmap = 0xc000; system_format.reserved_tracks = 2; - for(const auto &disk: media.disks) { + for(auto &disk: media.disks) { // Check for an ordinary catalogue. std::unique_ptr data_catalogue = Storage::Disk::CPM::GetCatalogue(disk, data_format); if(data_catalogue) { diff --git a/Analyser/Static/MSX/StaticAnalyser.cpp b/Analyser/Static/MSX/StaticAnalyser.cpp index 24385bea5..8f0fdb1f6 100644 --- a/Analyser/Static/MSX/StaticAnalyser.cpp +++ b/Analyser/Static/MSX/StaticAnalyser.cpp @@ -272,7 +272,7 @@ Analyser::Static::TargetList Analyser::Static::MSX::GetTargets(const Media &medi std::unique_ptr target(new Target); // Check tapes for loadable files. - for(const auto &tape : media.tapes) { + for(auto &tape : media.tapes) { std::vector files_on_tape = GetFiles(tape); if(!files_on_tape.empty()) { switch(files_on_tape.front().type) { diff --git a/Analyser/Static/Oric/StaticAnalyser.cpp b/Analyser/Static/Oric/StaticAnalyser.cpp index dcd16b924..35cbae8c1 100644 --- a/Analyser/Static/Oric/StaticAnalyser.cpp +++ b/Analyser/Static/Oric/StaticAnalyser.cpp @@ -23,15 +23,15 @@ using namespace Analyser::Static::Oric; static int Score(const Analyser::Static::MOS6502::Disassembly &disassembly, const std::set &rom_functions, const std::set &variable_locations) { int score = 0; - for(auto address : disassembly.outward_calls) score += (rom_functions.find(address) != rom_functions.end()) ? 1 : -1; - for(auto address : disassembly.external_stores) score += (variable_locations.find(address) != variable_locations.end()) ? 1 : -1; - for(auto address : disassembly.external_loads) score += (variable_locations.find(address) != variable_locations.end()) ? 1 : -1; + for(const auto address : disassembly.outward_calls) score += (rom_functions.find(address) != rom_functions.end()) ? 1 : -1; + for(const auto address : disassembly.external_stores) score += (variable_locations.find(address) != variable_locations.end()) ? 1 : -1; + for(const auto address : disassembly.external_loads) score += (variable_locations.find(address) != variable_locations.end()) ? 1 : -1; return score; } static int Basic10Score(const Analyser::Static::MOS6502::Disassembly &disassembly) { - std::set rom_functions = { + const std::set rom_functions = { 0x0228, 0x022b, 0xc3ca, 0xc3f8, 0xc448, 0xc47c, 0xc4b5, 0xc4e3, 0xc4e0, 0xc524, 0xc56f, 0xc5a2, 0xc5f8, 0xc60a, 0xc6a5, 0xc6de, 0xc719, 0xc738, 0xc773, 0xc824, 0xc832, 0xc841, 0xc8c1, 0xc8fe, 0xc91f, 0xc93f, 0xc941, 0xc91e, 0xc98b, 0xc996, 0xc9b3, 0xc9e0, 0xca0a, 0xca1c, @@ -47,7 +47,7 @@ static int Basic10Score(const Analyser::Static::MOS6502::Disassembly &disassembl 0xf43c, 0xf4ef, 0xf523, 0xf561, 0xf535, 0xf57b, 0xf5d3, 0xf71a, 0xf73f, 0xf7e4, 0xf7e0, 0xf82f, 0xf88f, 0xf8af, 0xf8b5, 0xf920, 0xf967, 0xf960, 0xf9c9, 0xfa14, 0xfa85, 0xfa9b, 0xfab1, 0xfac7, 0xfafa, 0xfb10, 0xfb26, 0xfbb6, 0xfbfe }; - std::set variable_locations = { + const std::set variable_locations = { 0x0228, 0x0229, 0x022a, 0x022b, 0x022c, 0x022d, 0x0230 }; @@ -55,7 +55,7 @@ static int Basic10Score(const Analyser::Static::MOS6502::Disassembly &disassembl } static int Basic11Score(const Analyser::Static::MOS6502::Disassembly &disassembly) { - std::set rom_functions = { + const std::set rom_functions = { 0x0238, 0x023b, 0x023e, 0x0241, 0x0244, 0x0247, 0xc3c6, 0xc3f4, 0xc444, 0xc47c, 0xc4a8, 0xc4d3, 0xc4e0, 0xc524, 0xc55f, 0xc592, 0xc5e8, 0xc5fa, 0xc692, 0xc6b3, 0xc6ee, 0xc70d, 0xc748, 0xc7fd, 0xc809, 0xc816, 0xc82f, 0xc855, 0xc8c1, 0xc915, 0xc952, 0xc971, 0xc973, 0xc9a0, 0xc9bd, 0xc9c8, 0xc9e5, 0xca12, @@ -72,7 +72,7 @@ static int Basic11Score(const Analyser::Static::MOS6502::Disassembly &disassembl 0xf88f, 0xf8af, 0xf8b5, 0xf920, 0xf967, 0xf9aa, 0xf9c9, 0xfa14, 0xfa9f, 0xfab5, 0xfacb, 0xfae1, 0xfb14, 0xfb2a, 0xfb40, 0xfbd0, 0xfc18 }; - std::set variable_locations = { + const std::set variable_locations = { 0x0244, 0x0245, 0x0246, 0x0247, 0x0248, 0x0249, 0x024a, 0x024b, 0x024c }; @@ -112,7 +112,7 @@ Analyser::Static::TargetList Analyser::Static::Oric::GetTargets(const Media &med std::vector tape_files = GetFiles(tape); tape->reset(); if(tape_files.size()) { - for(auto file : tape_files) { + for(const auto &file : tape_files) { if(file.data_type == File::MachineCode) { std::vector entry_points = {file.starting_address}; Analyser::Static::MOS6502::Disassembly disassembly = @@ -131,7 +131,7 @@ Analyser::Static::TargetList Analyser::Static::Oric::GetTargets(const Media &med if(!media.disks.empty()) { // Only the Microdisc is emulated right now, so accept only disks that it can boot from. - for(const auto &disk: media.disks) { + for(auto &disk: media.disks) { Storage::Encodings::MFM::Parser parser(true, disk); if(IsMicrodisc(parser)) { target->has_microdrive = true; diff --git a/Analyser/Static/StaticAnalyser.cpp b/Analyser/Static/StaticAnalyser.cpp index b822bc76c..bfd1a589c 100644 --- a/Analyser/Static/StaticAnalyser.cpp +++ b/Analyser/Static/StaticAnalyser.cpp @@ -174,7 +174,7 @@ TargetList Analyser::Static::GetTargets(const std::string &file_name) { #undef Append // Reset any tapes to their initial position - for(auto &target : targets) { + for(const auto &target : targets) { for(auto &tape : target->media.tapes) { tape->reset(); } diff --git a/Concurrency/AsyncTaskQueue.cpp b/Concurrency/AsyncTaskQueue.cpp index 070301007..4bde40272 100644 --- a/Concurrency/AsyncTaskQueue.cpp +++ b/Concurrency/AsyncTaskQueue.cpp @@ -98,7 +98,7 @@ void DeferringAsyncTaskQueue::perform() { std::shared_ptr>> deferred_tasks = deferred_tasks_; deferred_tasks_.reset(); enqueue([deferred_tasks] { - for(auto &function : *deferred_tasks) { + for(const auto &function : *deferred_tasks) { function(); } }); diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 56111292d..e119014bd 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -499,7 +499,7 @@ class ConcreteMachine: Range(0x0000, 0x0400), Range(0x1000, 0x2000), }}; - for(auto &video_range : video_ranges) { + for(const auto &video_range : video_ranges) { for(auto addr = video_range.start; addr < video_range.end; addr += 0x400) { auto destination_address = (addr & 0x1fff) | (((addr & 0x8000) >> 2) ^ 0x2000); if(processor_read_memory_map_[addr >> 10]) { diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index f0292fd11..1848dd312 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -302,7 +302,7 @@ class ConcreteMachine: } int drive_index = 0; - for(auto disk : media.disks) { + for(auto &disk : media.disks) { if(drive_index < 4) microdisc_.set_disk(disk, drive_index); drive_index++; } diff --git a/OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm b/OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm index e95259a07..499046097 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm @@ -18,7 +18,7 @@ ROMMachine::ROMFetcher CSROMFetcher() { return [] (const std::string &machine, const std::vector &names) -> std::vector>> { NSString *subDirectory = [@"ROMImages/" stringByAppendingString:[NSString stringWithUTF8String:machine.c_str()]]; std::vector>> results; - for(auto &name: names) { + for(const auto &name: names) { NSData *fileData = [[NSBundle mainBundle] dataForResource:[NSString stringWithUTF8String:name.c_str()] withExtension:nil subdirectory:subDirectory]; if(!fileData) diff --git a/OSBindings/Mac/Clock SignalTests/PCMPatchedTrackTests.mm b/OSBindings/Mac/Clock SignalTests/PCMPatchedTrackTests.mm index 2d66ebb4a..e0a2858cd 100644 --- a/OSBindings/Mac/Clock SignalTests/PCMPatchedTrackTests.mm +++ b/OSBindings/Mac/Clock SignalTests/PCMPatchedTrackTests.mm @@ -59,7 +59,7 @@ - (Storage::Time)timeForEvents:(const std::vector &)events { Storage::Time result(0); - for(auto event : events) { + for(const auto &event : events) { result += event.length; } return result; diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index 3631ce3ac..94a50728f 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -208,16 +208,16 @@ int main(int argc, char *argv[]) { std::cout << "Required machine type and configuration is determined from the file. Machines with further options:" << std::endl << std::endl; auto all_options = Machine::AllOptionsByMachineName(); - for(auto &machine_options: all_options) { + for(const auto &machine_options: all_options) { std::cout << machine_options.first << ":" << std::endl; - for(auto &option: machine_options.second) { + for(const auto &option: machine_options.second) { std::cout << '\t' << "--" << option->short_name; Configurable::ListOption *list_option = dynamic_cast(option.get()); if(list_option) { std::cout << "={"; bool is_first = true; - for(auto option: list_option->options) { + for(const auto &option: list_option->options) { if(!is_first) std::cout << '|'; is_first = false; std::cout << option; @@ -261,7 +261,7 @@ int main(int argc, char *argv[]) { machine_name = machine; std::vector>> results; - for(auto &name: names) { + for(const auto &name: names) { std::string local_path = "/usr/local/share/CLK/" + machine + "/" + name; FILE *file = std::fopen(local_path.c_str(), "rb"); if(!file) { @@ -300,7 +300,7 @@ int main(int argc, char *argv[]) { case ::Machine::Error::MissingROM: std::cerr << "Could not find system ROMs; please install to /usr/local/share/CLK/ or /usr/share/CLK/." << std::endl; std::cerr << "One or more of the following were needed but not found:" << std::endl; - for(auto &name: rom_names) { + for(const auto &name: rom_names) { std::cerr << machine_name << '/' << name << std::endl; } break; @@ -379,7 +379,7 @@ int main(int argc, char *argv[]) { configurable_device->set_selections(configurable_device->get_user_friendly_selections()); // Consider transcoding any list selections that map to Boolean options. - for(auto &option: configurable_device->get_options()) { + for(const auto &option: configurable_device->get_options()) { // Check for a corresponding selection. auto selection = arguments.selections.find(option->short_name); if(selection != arguments.selections.end()) { diff --git a/Outputs/CRT/Internals/Shaders/Shader.cpp b/Outputs/CRT/Internals/Shaders/Shader.cpp index 72fa3b086..e378b66ee 100644 --- a/Outputs/CRT/Internals/Shaders/Shader.cpp +++ b/Outputs/CRT/Internals/Shaders/Shader.cpp @@ -53,7 +53,7 @@ Shader::Shader(const std::string &vertex_shader, const std::string &fragment_sha glAttachShader(shader_program_, vertex); glAttachShader(shader_program_, fragment); - for(auto &binding : attribute_bindings) { + for(const auto &binding : attribute_bindings) { glBindAttribLocation(shader_program_, binding.index, binding.name.c_str()); } diff --git a/SignalProcessing/FIRFilter.cpp b/SignalProcessing/FIRFilter.cpp index 696dcf9af..5a9525af1 100644 --- a/SignalProcessing/FIRFilter.cpp +++ b/SignalProcessing/FIRFilter.cpp @@ -92,7 +92,7 @@ void FIRFilter::coefficients_for_idealised_filter_response(short *filter_coeffic std::vector FIRFilter::get_coefficients() const { std::vector coefficients; - for(auto short_coefficient: filter_coefficients_) { + for(const auto short_coefficient: filter_coefficients_) { coefficients.push_back(static_cast(short_coefficient) / FixedMultiplier); } return coefficients; @@ -129,7 +129,7 @@ FIRFilter::FIRFilter(std::size_t number_of_taps, float input_sample_rate, float } FIRFilter::FIRFilter(const std::vector &coefficients) { - for(auto coefficient: coefficients) { + for(const auto coefficient: coefficients) { filter_coefficients_.push_back(static_cast(coefficient * FixedMultiplier)); } } diff --git a/Storage/Disk/DiskImage/DiskImageImplementation.hpp b/Storage/Disk/DiskImage/DiskImageImplementation.hpp index c73e70bf3..0f051cfa4 100644 --- a/Storage/Disk/DiskImage/DiskImageImplementation.hpp +++ b/Storage/Disk/DiskImage/DiskImageImplementation.hpp @@ -24,7 +24,7 @@ template void DiskImageHolder::flush_tracks() { using TrackMap = std::map>; std::shared_ptr track_copies(new TrackMap); - for(auto &address : unwritten_tracks_) { + for(const auto &address : unwritten_tracks_) { track_copies->insert(std::make_pair(address, std::shared_ptr(cached_tracks_[address]->clone()))); } unwritten_tracks_.clear(); diff --git a/Storage/Disk/DiskImage/Formats/MFMSectorDump.cpp b/Storage/Disk/DiskImage/Formats/MFMSectorDump.cpp index b83f4a697..7e510cd68 100644 --- a/Storage/Disk/DiskImage/Formats/MFMSectorDump.cpp +++ b/Storage/Disk/DiskImage/Formats/MFMSectorDump.cpp @@ -42,7 +42,7 @@ void MFMSectorDump::set_tracks(const std::map(sectors_per_track_-1), sector_size_, is_double_density_); long file_offset = get_file_offset_for_position(track.first); diff --git a/Storage/Disk/DiskImage/Formats/OricMFMDSK.cpp b/Storage/Disk/DiskImage/Formats/OricMFMDSK.cpp index 8c0f754e4..38ec3ac75 100644 --- a/Storage/Disk/DiskImage/Formats/OricMFMDSK.cpp +++ b/Storage/Disk/DiskImage/Formats/OricMFMDSK.cpp @@ -113,7 +113,7 @@ std::shared_ptr OricMFMDSK::get_track_at_position(Track::Address address) } void OricMFMDSK::set_tracks(const std::map> &tracks) { - for(auto &track : tracks) { + for(const auto &track : tracks) { PCMSegment segment = Storage::Disk::track_serialisation(*track.second, Storage::Encodings::MFM::MFMBitLength); Storage::Encodings::MFM::Shifter shifter; shifter.set_is_double_density(true); diff --git a/Storage/Disk/DiskImage/Formats/Utility/ImplicitSectors.cpp b/Storage/Disk/DiskImage/Formats/Utility/ImplicitSectors.cpp index bf94f0c5f..ca0015a25 100644 --- a/Storage/Disk/DiskImage/Formats/Utility/ImplicitSectors.cpp +++ b/Storage/Disk/DiskImage/Formats/Utility/ImplicitSectors.cpp @@ -52,7 +52,7 @@ void Storage::Disk::decode_sectors(Track &track, uint8_t *const destination, uin is_double_density); std::size_t byte_size = static_cast(128 << sector_size); - for(auto &pair : sectors) { + for(const auto &pair : sectors) { if(pair.second.address.sector > last_sector) continue; if(pair.second.address.sector < first_sector) continue; if(pair.second.size != sector_size) continue; diff --git a/Storage/Disk/Encodings/MFM/Parser.cpp b/Storage/Disk/Encodings/MFM/Parser.cpp index 184612545..154beab9c 100644 --- a/Storage/Disk/Encodings/MFM/Parser.cpp +++ b/Storage/Disk/Encodings/MFM/Parser.cpp @@ -32,7 +32,7 @@ void Parser::install_sectors_from_track(const Storage::Disk::Track::Address &add is_mfm_); std::map sectors_by_id; - for(auto §or : sectors) { + for(const auto §or : sectors) { sectors_by_id.insert(std::make_pair(sector.second.address.sector, std::move(sector.second))); } sectors_by_address_by_track_.insert(std::make_pair(address, std::move(sectors_by_id))); diff --git a/Storage/Disk/Track/PCMTrack.cpp b/Storage/Disk/Track/PCMTrack.cpp index 9966b4376..caa1197a5 100644 --- a/Storage/Disk/Track/PCMTrack.cpp +++ b/Storage/Disk/Track/PCMTrack.cpp @@ -16,14 +16,14 @@ PCMTrack::PCMTrack() : segment_pointer_(0) {} PCMTrack::PCMTrack(const std::vector &segments) : PCMTrack() { // sum total length of all segments Time total_length; - for(auto segment : segments) { + for(const auto &segment : segments) { total_length += segment.length_of_a_bit * segment.number_of_bits; } total_length.simplify(); // each segment is then some proportion of the total; for them all to sum to 1 they'll // need to be adjusted to be - for(auto segment : segments) { + for(const auto &segment : segments) { Time original_length_of_segment = segment.length_of_a_bit * segment.number_of_bits; Time proportion_of_whole = original_length_of_segment / total_length; proportion_of_whole.simplify(); diff --git a/Storage/Tape/Formats/TZX.cpp b/Storage/Tape/Formats/TZX.cpp index 2695fae19..7a0c693a1 100644 --- a/Storage/Tape/Formats/TZX.cpp +++ b/Storage/Tape/Formats/TZX.cpp @@ -190,7 +190,7 @@ void TZX::get_generalised_segment(uint32_t output_symbols, uint8_t max_pulses_pe } // Output waves. - for(auto length : symbol.pulse_lengths) { + for(const auto length : symbol.pulse_lengths) { if(!length) break; post_pulse(length); }