Skip to content

Commit

Permalink
Replace copy with ´copy_n´
Browse files Browse the repository at this point in the history
  • Loading branch information
tygyh committed Aug 20, 2024
1 parent 4ff5ff2 commit ff618ff
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/FifoPlayer/FifoRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/HW/GBACore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteReal/IOWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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();

Expand Down
5 changes: 2 additions & 3 deletions Source/Core/DiscIO/Blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/CompressedBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/DiscIO/DirectoryBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/VolumeVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/UpdaterCommon/UpdaterCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ff618ff

Please sign in to comment.