mirror of
https://github.com/TomHarte/CLK.git
synced 2025-11-01 11:16:16 +00:00
Adopt std::ranges::copy where it is trivial to do so.
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
#include "Tape.hpp"
|
#include "Tape.hpp"
|
||||||
#include "Storage/Tape/Parsers/Commodore.hpp"
|
#include "Storage/Tape/Parsers/Commodore.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace Analyser::Static::Commodore;
|
using namespace Analyser::Static::Commodore;
|
||||||
|
|
||||||
std::vector<File> Analyser::Static::Commodore::GetFiles(Storage::Tape::TapeSerialiser &serialiser, TargetPlatform::Type type) {
|
std::vector<File> Analyser::Static::Commodore::GetFiles(Storage::Tape::TapeSerialiser &serialiser, TargetPlatform::Type type) {
|
||||||
@@ -37,7 +39,7 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(Storage::Tape::TapeSeria
|
|||||||
header = parser.get_next_header(serialiser);
|
header = parser.get_next_header(serialiser);
|
||||||
if(!header) continue;
|
if(!header) continue;
|
||||||
if(header->type != Storage::Tape::Commodore::Header::DataBlock) break;
|
if(header->type != Storage::Tape::Commodore::Header::DataBlock) break;
|
||||||
std::copy(header->data.begin(), header->data.end(), std::back_inserter(new_file.data));
|
std::ranges::copy(header->data, std::back_inserter(new_file.data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include "Outputs/Log.hpp"
|
#include "Outputs/Log.hpp"
|
||||||
#include "Activity/Observer.hpp"
|
#include "Activity/Observer.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace Archimedes {
|
namespace Archimedes {
|
||||||
|
|
||||||
/// Provides the mask with all bits set in the range [start, end], where start must be >= end.
|
/// Provides the mask with all bits set in the range [start, end], where start must be >= end.
|
||||||
@@ -53,9 +55,8 @@ struct MemoryController {
|
|||||||
// Copy in as many times as it'll fit.
|
// Copy in as many times as it'll fit.
|
||||||
std::size_t base = 0;
|
std::size_t base = 0;
|
||||||
while(base < rom_.size()) {
|
while(base < rom_.size()) {
|
||||||
std::copy(
|
std::ranges::copy(
|
||||||
rom.begin(),
|
rom,
|
||||||
rom.end(),
|
|
||||||
rom_.begin() + base);
|
rom_.begin() + base);
|
||||||
base += rom.size();
|
base += rom.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "Processors/Z80/Z80.hpp"
|
#include "Processors/Z80/Z80.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static constexpr uint16_t initial_pc = 0x0000;
|
static constexpr uint16_t initial_pc = 0x0000;
|
||||||
@@ -28,7 +30,7 @@ struct CapturingZ80: public CPU::Z80::BusHandler {
|
|||||||
|
|
||||||
template <typename Collection> CapturingZ80(const Collection &code) : z80_(*this) {
|
template <typename Collection> CapturingZ80(const Collection &code) : z80_(*this) {
|
||||||
// Take a copy of the code.
|
// Take a copy of the code.
|
||||||
std::copy(code.begin(), code.end(), ram_);
|
std::ranges::copy(code, ram_);
|
||||||
code_length_ = uint16_t(code.size());
|
code_length_ = uint16_t(code.size());
|
||||||
|
|
||||||
// Skip the three cycles the Z80 spends on a reset, and
|
// Skip the three cycles the Z80 spends on a reset, and
|
||||||
|
|||||||
@@ -742,7 +742,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!file) {
|
if(!file) {
|
||||||
std::copy(rom_checked_paths.begin(), rom_checked_paths.end(), std::back_inserter(checked_paths));
|
std::ranges::copy(rom_checked_paths, std::back_inserter(checked_paths));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,7 +757,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if(read == data.size()) {
|
if(read == data.size()) {
|
||||||
results[description.name] = std::move(data);
|
results[description.name] = std::move(data);
|
||||||
} else {
|
} else {
|
||||||
std::copy(rom_checked_paths.begin(), rom_checked_paths.end(), std::back_inserter(checked_paths));
|
std::ranges::copy(rom_checked_paths, std::back_inserter(checked_paths));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ std::string Reflection::Struct::description() const {
|
|||||||
/* Contractually, this serialises as BSON. */
|
/* Contractually, this serialises as BSON. */
|
||||||
std::vector<uint8_t> Reflection::Struct::serialise() const {
|
std::vector<uint8_t> Reflection::Struct::serialise() const {
|
||||||
auto push_name = [] (std::vector<uint8_t> &result, const std::string &name) {
|
auto push_name = [] (std::vector<uint8_t> &result, const std::string &name) {
|
||||||
std::copy(name.begin(), name.end(), std::back_inserter(result));
|
std::ranges::copy(name, std::back_inserter(result));
|
||||||
result.push_back(0);
|
result.push_back(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ std::vector<uint8_t> Reflection::Struct::serialise() const {
|
|||||||
|
|
||||||
const uint32_t string_length = uint32_t(text.size() + 1);
|
const uint32_t string_length = uint32_t(text.size() + 1);
|
||||||
push_int(string_length);
|
push_int(string_length);
|
||||||
std::copy(text.begin(), text.end(), std::back_inserter(result));
|
std::ranges::copy(text, std::back_inserter(result));
|
||||||
result.push_back(0);
|
result.push_back(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ std::vector<uint8_t> Reflection::Struct::serialise() const {
|
|||||||
auto source = reinterpret_cast<const std::vector<uint8_t> *>(get(key));
|
auto source = reinterpret_cast<const std::vector<uint8_t> *>(get(key));
|
||||||
push_int(uint32_t(source->size()));
|
push_int(uint32_t(source->size()));
|
||||||
result.push_back(0x00);
|
result.push_back(0x00);
|
||||||
std::copy(source->begin(), source->end(), std::back_inserter(result));
|
std::ranges::copy(*source, std::back_inserter(result));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +399,7 @@ std::vector<uint8_t> Reflection::Struct::serialise() const {
|
|||||||
|
|
||||||
const Reflection::Struct *const child = reinterpret_cast<const Reflection::Struct *>(get(key));
|
const Reflection::Struct *const child = reinterpret_cast<const Reflection::Struct *>(get(key));
|
||||||
const auto sub_document = child->serialise();
|
const auto sub_document = child->serialise();
|
||||||
std::copy(sub_document.begin(), sub_document.end(), std::back_inserter(result));
|
std::ranges::copy(sub_document, std::back_inserter(result));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,7 +441,7 @@ std::vector<uint8_t> Reflection::Struct::serialise() const {
|
|||||||
}
|
}
|
||||||
wrap_object(array);
|
wrap_object(array);
|
||||||
|
|
||||||
std::copy(array.begin(), array.end(), std::back_inserter(result));
|
std::ranges::copy(array, std::back_inserter(result));
|
||||||
} else {
|
} else {
|
||||||
append(result, key, key, type, 0);
|
append(result, key, key, type, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,12 @@
|
|||||||
|
|
||||||
#include "CSL.hpp"
|
#include "CSL.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include "Machines/AmstradCPC/Keyboard.hpp"
|
#include "Machines/AmstradCPC/Keyboard.hpp"
|
||||||
|
|
||||||
@@ -348,8 +349,8 @@ std::vector<CSL::Instruction> CSL::parse(const std::string &file_name) {
|
|||||||
std::vector<KeyEvent> down;
|
std::vector<KeyEvent> down;
|
||||||
std::vector<KeyEvent> up;
|
std::vector<KeyEvent> up;
|
||||||
while(append_typed(down, up, stream)) {
|
while(append_typed(down, up, stream)) {
|
||||||
std::copy(down.begin(), down.end(), std::back_inserter(argument));
|
std::ranges::copy(down, std::back_inserter(argument));
|
||||||
std::copy(up.begin(), up.end(), std::back_inserter(argument));
|
std::ranges::copy(up, std::back_inserter(argument));
|
||||||
down.clear();
|
down.clear();
|
||||||
up.clear();
|
up.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "Storage/Disk/Encodings/MFM/Parser.hpp"
|
#include "Storage/Disk/Encodings/MFM/Parser.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
@@ -113,7 +114,7 @@ std::optional<FAT::Volume> FAT::GetVolume(const std::shared_ptr<Storage::Disk::D
|
|||||||
if(!fat_sector || fat_sector->samples.empty() || fat_sector->samples[0].size() != volume.bytes_per_sector) {
|
if(!fat_sector || fat_sector->samples.empty() || fat_sector->samples[0].size() != volume.bytes_per_sector) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
std::copy(fat_sector->samples[0].begin(), fat_sector->samples[0].end(), std::back_inserter(source_fat));
|
std::ranges::copy(fat_sector->samples[0], std::back_inserter(source_fat));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode the FAT.
|
// Decode the FAT.
|
||||||
@@ -135,7 +136,7 @@ std::optional<FAT::Volume> FAT::GetVolume(const std::shared_ptr<Storage::Disk::D
|
|||||||
if(!sector || sector->samples.empty() || sector->samples[0].size() != volume.bytes_per_sector) {
|
if(!sector || sector->samples.empty() || sector->samples[0].size() != volume.bytes_per_sector) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
std::copy(sector->samples[0].begin(), sector->samples[0].end(), std::back_inserter(root_directory));
|
std::ranges::copy(sector->samples[0], std::back_inserter(root_directory));
|
||||||
}
|
}
|
||||||
volume.root_directory = directory_from(root_directory);
|
volume.root_directory = directory_from(root_directory);
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ std::optional<std::vector<uint8_t>> FAT::GetFile(const std::shared_ptr<Storage::
|
|||||||
if(!sector_contents || sector_contents->samples.empty() || sector_contents->samples[0].size() != volume.bytes_per_sector) {
|
if(!sector_contents || sector_contents->samples.empty() || sector_contents->samples[0].size() != volume.bytes_per_sector) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
std::copy(sector_contents->samples[0].begin(), sector_contents->samples[0].end(), std::back_inserter(contents));
|
std::ranges::copy(sector_contents->samples[0], std::back_inserter(contents));
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster = volume.fat[cluster];
|
cluster = volume.fat[cluster];
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "DirectAccessDevice.hpp"
|
#include "DirectAccessDevice.hpp"
|
||||||
#include "Outputs/Log.hpp"
|
#include "Outputs/Log.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace SCSI;
|
using namespace SCSI;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -30,7 +32,7 @@ bool DirectAccessDevice::read(const Target::CommandState &state, Target::Respond
|
|||||||
std::vector<uint8_t> output = device_->get_block(specs.address);
|
std::vector<uint8_t> output = device_->get_block(specs.address);
|
||||||
for(uint32_t offset = 1; offset < specs.number_of_blocks; ++offset) {
|
for(uint32_t offset = 1; offset < specs.number_of_blocks; ++offset) {
|
||||||
const auto next_block = device_->get_block(specs.address + offset);
|
const auto next_block = device_->get_block(specs.address + offset);
|
||||||
std::copy(next_block.begin(), next_block.end(), std::back_inserter(output));
|
std::ranges::copy(next_block, std::back_inserter(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
responder.send_data(std::move(output), [] (const Target::CommandState &, Target::Responder &responder) {
|
responder.send_data(std::move(output), [] (const Target::CommandState &, Target::Responder &responder) {
|
||||||
|
|||||||
Reference in New Issue
Block a user