Merge pull request #13095 from mitaclaw/ranges-modernization-6-n

Ranges Algorithms Modernization - N
This commit is contained in:
Tilka 2024-10-11 20:28:06 +01:00 committed by GitHub
commit d2a56b321f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 18 additions and 21 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.fifoPosition = (u32)(m_FifoData.size());
memUpdate.type = type; memUpdate.type = type;
memUpdate.data.resize(size); 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)); m_CurrentFrame.memoryUpdates.push_back(std::move(memUpdate));
} }

View File

@ -543,8 +543,7 @@ void Core::RunCommand(Command& command)
{ {
int recvd = GBASIOJOYSendCommand( int recvd = GBASIOJOYSendCommand(
&m_sio_driver, static_cast<GBASIOJOYCommand>(command.buffer[0]), &command.buffer[1]); &m_sio_driver, static_cast<GBASIOJOYCommand>(command.buffer[0]), &command.buffer[1]);
std::copy(command.buffer.begin() + 1, command.buffer.begin() + 1 + recvd, std::copy_n(command.buffer.begin() + 1, recvd, std::back_inserter(m_response));
std::back_inserter(m_response));
} }
if (m_thread && !m_response_ready) 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. // This is currently needed by the Toshiba Bluetooth Stack.
if ((write_method == WWM_WRITE_FILE_LARGEST_REPORT_SIZE) && (MAX_PAYLOAD > len)) 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); std::fill(resized_buffer + len, resized_buffer + MAX_PAYLOAD, 0);
write_buffer = resized_buffer + 1; write_buffer = resized_buffer + 1;
bytes_to_write = MAX_PAYLOAD - 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()); m_queue.push_back(Packet());
auto& packet = m_queue.back(); auto& packet = m_queue.back();
std::copy(data, data + size, packet.data); std::copy_n(data, size, packet.data);
packet.size = size; packet.size = size;
packet.conn_handle = conn_handle; packet.conn_handle = conn_handle;
} }
@ -438,7 +438,7 @@ void BluetoothEmuDevice::ACLPool::WriteToEndpoint(const USB::V0BulkMessage& endp
header->length = size; header->length = size;
// Write the packet to the buffer // 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(); 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 can_read = m_block_size * cache->num_blocks - read_offset;
u32 was_read = static_cast<u32>(std::min<u64>(can_read, remain)); 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, std::copy_n(cache->data.begin() + read_offset, was_read, out_ptr);
out_ptr);
offset += was_read; offset += was_read;
out_ptr += was_read; out_ptr += was_read;
@ -204,7 +203,7 @@ u32 SectorReader::ReadChunk(u8* buffer, u64 chunk_num)
{ {
if (!GetBlock(block_num + i, buffer)) 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; return i;
} }
buffer += m_block_size; buffer += m_block_size;

View File

@ -130,7 +130,7 @@ bool CompressedBlobReader::GetBlock(u64 block_num, u8* out_ptr)
if (uncompressed) 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 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)) else if (std::holds_alternative<ContentMemory>(m_content_source))
{ {
const auto& content = std::get<ContentMemory>(m_content_source); const auto& content = std::get<ContentMemory>(m_content_source);
std::copy(content->begin() + offset_in_content, std::copy_n(content->begin() + offset_in_content, bytes_to_read, *buffer);
content->begin() + offset_in_content + bytes_to_read, *buffer);
} }
else if (std::holds_alternative<ContentPartition>(m_content_source)) else if (std::holds_alternative<ContentPartition>(m_content_source))
{ {

View File

@ -78,8 +78,8 @@ bool LaggedFibonacciGenerator::GetSeed(const u32* data, size_t size, size_t data
const size_t data_offset_mod_k = data_offset % LFG_K; const size_t data_offset_mod_k = data_offset % LFG_K;
const size_t data_offset_div_k = data_offset / LFG_K; const size_t data_offset_div_k = data_offset / LFG_K;
std::copy(data, data + LFG_K - data_offset_mod_k, lfg->m_buffer.data() + data_offset_mod_k); std::copy_n(data, LFG_K - data_offset_mod_k, lfg->m_buffer.data() + data_offset_mod_k);
std::copy(data + LFG_K - data_offset_mod_k, data + LFG_K, lfg->m_buffer.data()); std::copy_n(data + LFG_K - data_offset_mod_k, data_offset_mod_k, lfg->m_buffer.data());
lfg->Backward(0, data_offset_mod_k); lfg->Backward(0, data_offset_mod_k);

View File

@ -28,8 +28,8 @@ void Replace(u64 offset, u64 size, u8* out_ptr, u64 replace_offset, u64 replace_
if (replace_end > replace_start) if (replace_end > replace_start)
{ {
std::copy(replace_ptr + (replace_start - replace_offset), std::copy_n(replace_ptr + (replace_start - replace_offset), replace_end - replace_start,
replace_ptr + (replace_end - replace_offset), out_ptr + (replace_start - offset)); out_ptr + (replace_start - offset));
} }
} }

View File

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

View File

@ -1635,7 +1635,7 @@ WIARVZFileReader<RVZ>::ProcessAndCompress(CompressThreadState* state, CompressPa
const size_t size = state->compressor->GetSize(); const size_t size = state->compressor->GetSize();
entry.main_data.resize(size); entry.main_data.resize(size);
std::copy(data, data + size, entry.main_data.data()); std::copy_n(data, size, entry.main_data.data());
if (compressed_exception_lists) if (compressed_exception_lists)
entry.exception_lists.clear(); entry.exception_lists.clear();

View File

@ -3,6 +3,7 @@
#include "UpdaterCommon/UpdaterCommon.h" #include "UpdaterCommon/UpdaterCommon.h"
#include <algorithm>
#include <array> #include <array>
#include <memory> #include <memory>
#include <optional> #include <optional>
@ -150,7 +151,7 @@ Manifest::Hash ComputeHash(const std::string& contents)
false); false);
Manifest::Hash out; Manifest::Hash out;
std::copy(full.begin(), full.begin() + 16, out.begin()); std::copy_n(full.begin(), 16, out.begin());
return out; return out;
} }

View File

@ -60,7 +60,7 @@ inline void CON_BlankRow(const int y)
int columns = 0, rows = 0; int columns = 0, rows = 0;
CON_GetMetrics(&columns, &rows); CON_GetMetrics(&columns, &rows);
char blank[columns]; char blank[columns];
std::fill(blank, blank + columns, ' '); std::fill_n(blank, columns, ' ');
blank[columns - 1] = '\0'; blank[columns - 1] = '\0';
CON_Printf(0, y, "%s", blank); CON_Printf(0, y, "%s", blank);
} }