Modernize `std::copy` with ranges

This commit is contained in:
mitaclaw 2024-09-27 22:30:01 -07:00
parent 249defa72b
commit 7ce170f138
14 changed files with 22 additions and 22 deletions

View File

@ -252,8 +252,8 @@ Signature Sign(const u8* key, const u8* hash)
bn_mul(s.data.data(), minv, kk, ec_N, 30);
Signature signature;
std::copy(r.data.cbegin(), r.data.cend(), signature.begin());
std::copy(s.data.cbegin(), s.data.cend(), signature.begin() + 30);
std::ranges::copy(r.data, signature.begin());
std::ranges::copy(s.data, signature.begin() + 30);
return signature;
}

View File

@ -36,10 +36,10 @@ MACAddress GenerateMacAddress(const MACConsumer type)
switch (type)
{
case MACConsumer::BBA:
std::copy(oui_bba.begin(), oui_bba.end(), mac.begin());
std::ranges::copy(oui_bba, mac.begin());
break;
case MACConsumer::IOS:
std::copy(oui_ios.begin(), oui_ios.end(), mac.begin());
std::ranges::copy(oui_ios, mac.begin());
break;
}

View File

@ -500,7 +500,7 @@ void FifoPlayer::WriteMemory(const MemoryUpdate& memUpdate)
else
mem = &memory.GetRAM()[memUpdate.address & memory.GetRamMask()];
std::copy(memUpdate.data.begin(), memUpdate.data.end(), mem);
std::ranges::copy(memUpdate.data, mem);
}
void FifoPlayer::WriteFifo(const u8* data, u32 start, u32 end)

View File

@ -93,7 +93,7 @@ int CSIDevice_GBAEmu::RunBuffer(u8* buffer, int request_length)
std::vector<u8> response = m_core->GetJoybusResponse();
if (response.empty())
return -1;
std::copy(response.begin(), response.end(), buffer);
std::ranges::copy(response, buffer);
#ifdef _DEBUG
const Common::Log::LogLevel log_level =

View File

@ -422,7 +422,7 @@ public:
if (data)
{
std::vector<u8> file_data_enc(Common::AlignUp(data->size(), BLOCK_SZ));
std::copy(data->cbegin(), data->cend(), file_data_enc.begin());
std::ranges::copy(*data, file_data_enc.begin());
m_iosc.Encrypt(IOS::HLE::IOSC::HANDLE_SD_KEY, file_hdr.iv.data(), file_data_enc.data(),
file_data_enc.size(), file_data_enc.data(), IOS::PID_ES);
if (!m_file.WriteBytes(file_data_enc.data(), file_data_enc.size()))

View File

@ -33,14 +33,14 @@ std::optional<IPCReply> ShaDevice::Open(const OpenRequest& request)
static void ConvertContext(const ShaDevice::ShaContext& src, mbedtls_sha1_context* dest)
{
std::copy(std::begin(src.length), std::end(src.length), std::begin(dest->total));
std::copy(std::begin(src.states), std::end(src.states), std::begin(dest->state));
std::ranges::copy(src.length, std::begin(dest->total));
std::ranges::copy(src.states, std::begin(dest->state));
}
static void ConvertContext(const mbedtls_sha1_context& src, ShaDevice::ShaContext* dest)
{
std::copy(std::begin(src.total), std::end(src.total), std::begin(dest->length));
std::copy(std::begin(src.state), std::end(src.state), std::begin(dest->states));
std::ranges::copy(src.total, std::begin(dest->length));
std::ranges::copy(src.state, std::begin(dest->states));
}
HLE::ReturnCode ShaDevice::ProcessShaCommand(ShaIoctlv command, const IOCtlVRequest& request)

View File

@ -535,7 +535,7 @@ HLE::ReturnCode TicketReader::Unpersonalise(HLE::IOSC& iosc)
sizeof(Ticket::title_key), key.data(), PID_ES);
// Finally, IOS copies the decrypted title key back to the ticket buffer.
if (ret == IPC_SUCCESS)
std::copy(key.cbegin(), key.cend(), ticket_begin + offsetof(Ticket, title_key));
std::ranges::copy(key, ticket_begin + offsetof(Ticket, title_key));
return ret;
}

View File

@ -817,7 +817,7 @@ ReturnCode ESCore::ExportContentData(Context& context, u32 content_fd, u8* data,
if (encrypt_ret != IPC_SUCCESS)
return encrypt_ret;
std::copy(output.cbegin(), output.cend(), data);
std::ranges::copy(output, data);
return IPC_SUCCESS;
}

View File

@ -147,7 +147,7 @@ ReturnCode ESCore::GetTicketFromView(const u8* ticket_view, u8* ticket, u32* tic
return ES_EACCES;
}
std::copy(ticket_bytes.begin(), ticket_bytes.end(), ticket);
std::ranges::copy(ticket_bytes, ticket);
return IPC_SUCCESS;
}

View File

@ -551,7 +551,7 @@ void IOSC::Sign(u8* sig_out, u8* ap_cert_out, u64 title_id, const u8* data, u32
// Sign the data.
const auto data_digest = Common::SHA1::CalculateDigest(data, data_size);
const auto signature = Common::ec::Sign(ap_priv.data(), data_digest.data());
std::copy(signature.cbegin(), signature.cend(), sig_out);
std::ranges::copy(signature, sig_out);
}
void IOSC::LoadDefaultEntries()

View File

@ -51,8 +51,8 @@ BluetoothEmuDevice::BluetoothEmuDevice(EmulationKernel& ios, const std::string&
const bdaddr_t tmp_bd = {0x11, 0x02, 0x19, 0x79, 0, i};
// Previous records can be safely overwritten, since they are backed up
std::copy(tmp_bd.begin(), tmp_bd.end(), std::rbegin(bt_dinf.active[i].bdaddr));
std::copy(tmp_bd.begin(), tmp_bd.end(), std::rbegin(bt_dinf.registered[i].bdaddr));
std::ranges::copy(tmp_bd, std::rbegin(bt_dinf.active[i].bdaddr));
std::ranges::copy(tmp_bd, std::rbegin(bt_dinf.registered[i].bdaddr));
const auto& wm_name =
(i == WIIMOTE_BALANCE_BOARD) ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01";

View File

@ -482,9 +482,9 @@ bool BluetoothRealDevice::SendHCIStoreLinkKeyCommand()
auto iterator = packet.begin() + sizeof(hci_cmd_hdr_t) + sizeof(hci_write_stored_link_key_cp);
for (const auto& entry : m_link_keys)
{
std::copy(entry.first.begin(), entry.first.end(), iterator);
std::ranges::copy(entry.first, iterator);
iterator += entry.first.size();
std::copy(entry.second.begin(), entry.second.end(), iterator);
std::ranges::copy(entry.second, iterator);
iterator += entry.second.size();
}
@ -737,7 +737,7 @@ void BluetoothRealDevice::HandleBulkOrIntrTransfer(libusb_transfer* tr)
hci_link_key_notification_ep notification;
std::memcpy(&notification, tr->buffer + sizeof(hci_event_hdr_t), sizeof(notification));
linkkey_t key;
std::copy(std::begin(notification.key), std::end(notification.key), std::begin(key));
std::ranges::copy(notification.key, std::begin(key));
m_link_keys[notification.bdaddr] = key;
}
else if (event == HCI_EVENT_COMMAND_COMPL)

View File

@ -1100,7 +1100,7 @@ void MovieManager::LoadInput(const std::string& movie_path)
"read-only mode off. Otherwise you'll probably get a desync.",
byte_offset, byte_offset);
std::copy(movInput.begin(), movInput.end(), m_temp_input.begin());
std::ranges::copy(movInput, m_temp_input.begin());
}
else
{

View File

@ -192,7 +192,7 @@ bool SysConf::Save() const
// Make sure the buffer size is 0x4000 bytes now and write the footer.
buffer.resize(SYSCONF_SIZE);
constexpr std::array<u8, 4> footer = {{'S', 'C', 'e', 'd'}};
std::copy(footer.cbegin(), footer.cend(), buffer.end() - footer.size());
std::ranges::copy(footer, buffer.end() - footer.size());
// Write the new data.
const std::string temp_file = "/tmp/SYSCONF";