Replace `copy` with ´copy_n´

This commit is contained in:
Dr. Dystopia 2024-08-19 09:55:44 +02:00
parent 4ff5ff2772
commit ff618ff215
9 changed files with 11 additions and 14 deletions

View File

@ -382,7 +382,7 @@ void FifoRecorder::UseMemory(u32 address, u32 size, MemoryUpdate::Type type, boo
memUpdate.fifoPosition = (u32)(m_FifoData.size());
memUpdate.type = type;
memUpdate.data.resize(size);
std::copy(newData, newData + size, memUpdate.data.begin());
std::copy_n(newData, size, memUpdate.data.begin());
m_CurrentFrame.memoryUpdates.push_back(std::move(memUpdate));
}

View File

@ -543,8 +543,7 @@ void Core::RunCommand(Command& command)
{
int recvd = GBASIOJOYSendCommand(
&m_sio_driver, static_cast<GBASIOJOYCommand>(command.buffer[0]), &command.buffer[1]);
std::copy(command.buffer.begin() + 1, command.buffer.begin() + 1 + recvd,
std::back_inserter(m_response));
std::copy_n(command.buffer.begin() + 1, recvd, std::back_inserter(m_response));
}
if (m_thread && !m_response_ready)

View File

@ -275,7 +275,7 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
// This is currently needed by the Toshiba Bluetooth Stack.
if ((write_method == WWM_WRITE_FILE_LARGEST_REPORT_SIZE) && (MAX_PAYLOAD > len))
{
std::copy(buf, buf + len, resized_buffer);
std::copy_n(buf, len, resized_buffer);
std::fill(resized_buffer + len, resized_buffer + MAX_PAYLOAD, 0);
write_buffer = resized_buffer + 1;
bytes_to_write = MAX_PAYLOAD - 1;

View File

@ -413,7 +413,7 @@ void BluetoothEmuDevice::ACLPool::Store(const u8* data, const u16 size, const u1
m_queue.push_back(Packet());
auto& packet = m_queue.back();
std::copy(data, data + size, packet.data);
std::copy_n(data, size, packet.data);
packet.size = size;
packet.conn_handle = conn_handle;
}
@ -438,7 +438,7 @@ void BluetoothEmuDevice::ACLPool::WriteToEndpoint(const USB::V0BulkMessage& endp
header->length = size;
// Write the packet to the buffer
std::copy(data, data + size, (u8*)header + sizeof(hci_acldata_hdr_t));
std::copy_n(data, size, (u8*)header + sizeof(hci_acldata_hdr_t));
m_queue.pop_front();

View File

@ -153,8 +153,7 @@ bool SectorReader::Read(u64 offset, u64 size, u8* out_ptr)
u32 can_read = m_block_size * cache->num_blocks - read_offset;
u32 was_read = static_cast<u32>(std::min<u64>(can_read, remain));
std::copy(cache->data.begin() + read_offset, cache->data.begin() + read_offset + was_read,
out_ptr);
std::copy_n(cache->data.begin() + read_offset, was_read, out_ptr);
offset += was_read;
out_ptr += was_read;
@ -204,7 +203,7 @@ u32 SectorReader::ReadChunk(u8* buffer, u64 chunk_num)
{
if (!GetBlock(block_num + i, buffer))
{
std::fill(buffer, buffer + (cnt_blocks - i) * m_block_size, 0u);
std::fill_n(buffer, (cnt_blocks - i) * m_block_size, 0u);
return i;
}
buffer += m_block_size;

View File

@ -130,7 +130,7 @@ bool CompressedBlobReader::GetBlock(u64 block_num, u8* out_ptr)
if (uncompressed)
{
std::copy(m_zlib_buffer.begin(), m_zlib_buffer.begin() + comp_block_size, out_ptr);
std::copy_n(m_zlib_buffer.begin(), comp_block_size, out_ptr);
}
else
{

View File

@ -107,8 +107,7 @@ bool DiscContent::Read(u64* offset, u64* length, u8** buffer, DirectoryBlobReade
else if (std::holds_alternative<ContentMemory>(m_content_source))
{
const auto& content = std::get<ContentMemory>(m_content_source);
std::copy(content->begin() + offset_in_content,
content->begin() + offset_in_content + bytes_to_read, *buffer);
std::copy_n(content->begin() + offset_in_content, bytes_to_read, *buffer);
}
else if (std::holds_alternative<ContentPartition>(m_content_source))
{

View File

@ -1302,7 +1302,7 @@ void VolumeVerifier::Finish()
m_result.hashes.crc32 = std::vector<u8>(4);
const u32 crc32_be = Common::swap32(m_crc32_context);
const u8* crc32_be_ptr = reinterpret_cast<const u8*>(&crc32_be);
std::copy(crc32_be_ptr, crc32_be_ptr + 4, m_result.hashes.crc32.begin());
std::copy_n(crc32_be_ptr, 4, m_result.hashes.crc32.begin());
}
if (m_hashes_to_calculate.md5)

View File

@ -150,7 +150,7 @@ Manifest::Hash ComputeHash(const std::string& contents)
false);
Manifest::Hash out;
std::copy(full.begin(), full.begin() + 16, out.begin());
std::copy_n(full.begin(), 16, out.begin());
return out;
}