diff --git a/Source/Core/Common/Assembler/GekkoLexer.cpp b/Source/Core/Common/Assembler/GekkoLexer.cpp index 4cfb1c6243..595df5cbf5 100644 --- a/Source/Core/Common/Assembler/GekkoLexer.cpp +++ b/Source/Core/Common/Assembler/GekkoLexer.cpp @@ -486,7 +486,7 @@ void Lexer::EatAndReset() SetIdentifierMatchRule(IdentifierMatchRule::Typical); } -std::optional Lexer::RunDfa(const std::vector& dfa) const +std::optional Lexer::RunDfa(std::span dfa) const { size_t dfa_index = 0; bool transition_found; diff --git a/Source/Core/Common/Assembler/GekkoLexer.h b/Source/Core/Common/Assembler/GekkoLexer.h index f20a951e97..f01ddcdc3b 100644 --- a/Source/Core/Common/Assembler/GekkoLexer.h +++ b/Source/Core/Common/Assembler/GekkoLexer.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -166,7 +167,7 @@ public: } private: - std::optional RunDfa(const std::vector& dfa) const; + std::optional RunDfa(std::span dfa) const; void SkipWs() const; void FeedbackTokens() const; bool IdentifierHeadExtra(char h) const; diff --git a/Source/Core/Common/Debug/Watches.cpp b/Source/Core/Common/Debug/Watches.cpp index 2ffad54b82..6d4b07cc5c 100644 --- a/Source/Core/Common/Debug/Watches.cpp +++ b/Source/Core/Common/Debug/Watches.cpp @@ -89,7 +89,7 @@ void Watches::RemoveWatch(std::size_t index) m_watches.erase(m_watches.begin() + index); } -void Watches::LoadFromStrings(const std::vector& watches) +void Watches::LoadFromStrings(std::span watches) { for (const std::string& watch : watches) { diff --git a/Source/Core/Common/Debug/Watches.h b/Source/Core/Common/Debug/Watches.h index fc16adb826..cf4ee2b179 100644 --- a/Source/Core/Common/Debug/Watches.h +++ b/Source/Core/Common/Debug/Watches.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include @@ -42,7 +43,7 @@ public: void DisableWatch(std::size_t index); bool HasEnabledWatch(u32 address) const; void RemoveWatch(std::size_t index); - void LoadFromStrings(const std::vector& watches); + void LoadFromStrings(std::span watches); std::vector SaveToStrings() const; void Clear(); diff --git a/Source/Core/Common/HttpRequest.cpp b/Source/Core/Common/HttpRequest.cpp index d3860594e0..94a466434a 100644 --- a/Source/Core/Common/HttpRequest.cpp +++ b/Source/Core/Common/HttpRequest.cpp @@ -96,13 +96,13 @@ HttpRequest::Response HttpRequest::Get(const std::string& url, const Headers& he return m_impl->Fetch(url, Impl::Method::GET, headers, nullptr, 0, codes); } -HttpRequest::Response HttpRequest::Post(const std::string& url, const std::vector& payload, +HttpRequest::Response HttpRequest::Post(const std::string& url, std::span payload, const Headers& headers, AllowedReturnCodes codes) { return m_impl->Fetch(url, Impl::Method::POST, headers, payload.data(), payload.size(), codes); } -HttpRequest::Response HttpRequest::Post(const std::string& url, const std::string& payload, +HttpRequest::Response HttpRequest::Post(const std::string& url, std::string_view payload, const Headers& headers, AllowedReturnCodes codes) { return m_impl->Fetch(url, Impl::Method::POST, headers, diff --git a/Source/Core/Common/HttpRequest.h b/Source/Core/Common/HttpRequest.h index 4f1a9798d5..b92fa2f29f 100644 --- a/Source/Core/Common/HttpRequest.h +++ b/Source/Core/Common/HttpRequest.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "Common/CommonTypes.h" @@ -50,9 +51,9 @@ public: std::string GetHeaderValue(std::string_view name) const; Response Get(const std::string& url, const Headers& headers = {}, AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only); - Response Post(const std::string& url, const std::vector& payload, const Headers& headers = {}, + Response Post(const std::string& url, std::span payload, const Headers& headers = {}, AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only); - Response Post(const std::string& url, const std::string& payload, const Headers& headers = {}, + Response Post(const std::string& url, std::string_view payload, const Headers& headers = {}, AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only); Response PostMultiform(const std::string& url, std::span multiform, diff --git a/Source/Core/Common/Network.cpp b/Source/Core/Common/Network.cpp index d44d106da5..58994c635d 100644 --- a/Source/Core/Common/Network.cpp +++ b/Source/Core/Common/Network.cpp @@ -462,7 +462,7 @@ DHCPBody::DHCPBody(u32 transaction, const MACAddress& client_address, u32 new_ip DHCPPacket::DHCPPacket() = default; -DHCPPacket::DHCPPacket(const std::vector& data) +DHCPPacket::DHCPPacket(std::span data) { if (data.size() < DHCPBody::SIZE) return; @@ -489,7 +489,7 @@ DHCPPacket::DHCPPacket(const std::vector& data) } } -void DHCPPacket::AddOption(u8 fnc, const std::vector& params) +void DHCPPacket::AddOption(u8 fnc, std::span params) { if (params.size() > 255) return; @@ -507,7 +507,7 @@ std::vector DHCPPacket::Build() const { result.insert(result.end(), opt.begin(), opt.end()); } - const std::vector no_option = {255, 0, 0, 0}; + constexpr auto no_option = std::to_array({255, 0, 0, 0}); result.insert(result.end(), no_option.begin(), no_option.end()); return result; diff --git a/Source/Core/Common/Network.h b/Source/Core/Common/Network.h index 5e0da6559e..3ae1211d03 100644 --- a/Source/Core/Common/Network.h +++ b/Source/Core/Common/Network.h @@ -4,7 +4,9 @@ #pragma once #include +#include #include +#include #include #include #include @@ -183,8 +185,12 @@ static_assert(sizeof(DHCPBody) == DHCPBody::SIZE); struct DHCPPacket { DHCPPacket(); - DHCPPacket(const std::vector& data); - void AddOption(u8 fnc, const std::vector& params); + DHCPPacket(std::span data); + void AddOption(u8 fnc, std::span params); + void AddOption(u8 fnc, std::initializer_list params) + { + AddOption(fnc, {params.begin(), params.end()}); + } std::vector Build() const; DHCPBody body; diff --git a/Source/Core/Core/Boot/DolReader.cpp b/Source/Core/Core/Boot/DolReader.cpp index c78cd36fcb..0ec828c519 100644 --- a/Source/Core/Core/Boot/DolReader.cpp +++ b/Source/Core/Core/Boot/DolReader.cpp @@ -31,7 +31,7 @@ DolReader::DolReader(const std::string& filename) : BootExecutableReader(filenam DolReader::~DolReader() = default; -bool DolReader::Initialize(const std::vector& buffer) +bool DolReader::Initialize(std::span buffer) { if (buffer.size() < sizeof(SDolHeader) || buffer.size() > UINT32_MAX) return false; diff --git a/Source/Core/Core/Boot/DolReader.h b/Source/Core/Core/Boot/DolReader.h index 5ef8500610..badd52bc90 100644 --- a/Source/Core/Core/Boot/DolReader.h +++ b/Source/Core/Core/Boot/DolReader.h @@ -65,7 +65,7 @@ private: bool m_is_ancast; // Copy sections to internal buffers - bool Initialize(const std::vector& buffer); + bool Initialize(std::span buffer); bool LoadAncastIntoMemory(Core::System& system) const; }; diff --git a/Source/Core/Core/CheatSearch.cpp b/Source/Core/Core/CheatSearch.cpp index 063a09a582..aba2199682 100644 --- a/Source/Core/Core/CheatSearch.cpp +++ b/Source/Core/Core/CheatSearch.cpp @@ -111,7 +111,7 @@ TryReadValueFromEmulatedMemory(const Core::CPUThreadGuard& guard, u32 addr, template auto Cheats::NewSearch(const Core::CPUThreadGuard& guard, - const std::vector& memory_ranges, + std::span memory_ranges, PowerPC::RequestedAddressSpace address_space, bool aligned, const std::function& validator) -> std::expected>, SearchErrorCode> @@ -164,7 +164,7 @@ auto Cheats::NewSearch(const Core::CPUThreadGuard& guard, template auto Cheats::NextSearch( - const Core::CPUThreadGuard& guard, const std::vector>& previous_results, + const Core::CPUThreadGuard& guard, std::span> previous_results, PowerPC::RequestedAddressSpace address_space, const std::function& validator) -> std::expected>, SearchErrorCode> diff --git a/Source/Core/Core/CheatSearch.h b/Source/Core/Core/CheatSearch.h index 7d1c089835..3c83484ab3 100644 --- a/Source/Core/Core/CheatSearch.h +++ b/Source/Core/Core/CheatSearch.h @@ -117,7 +117,7 @@ std::vector GetValueAsByteVector(const SearchValue& value); // for which the given validator returns true. template std::expected>, SearchErrorCode> -NewSearch(const Core::CPUThreadGuard& guard, const std::vector& memory_ranges, +NewSearch(const Core::CPUThreadGuard& guard, std::span memory_ranges, PowerPC::RequestedAddressSpace address_space, bool aligned, const std::function& validator); @@ -125,7 +125,7 @@ NewSearch(const Core::CPUThreadGuard& guard, const std::vector& mem // which the given validator returns true. template std::expected>, SearchErrorCode> -NextSearch(const Core::CPUThreadGuard& guard, const std::vector>& previous_results, +NextSearch(const Core::CPUThreadGuard& guard, std::span> previous_results, PowerPC::RequestedAddressSpace address_space, const std::function& validator); diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 147aeedf50..993c0778d8 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -367,7 +367,7 @@ std::vector GetIsoPaths() return paths; } -void SetIsoPaths(const std::vector& paths) +void SetIsoPaths(std::span paths) { size_t old_size = MathUtil::SaturatingCast(Config::Get(Config::MAIN_ISO_PATH_COUNT)); size_t new_size = paths.size(); diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index a1baf26242..323a22894d 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -218,7 +218,7 @@ extern const Info MAIN_GDB_PORT; extern const Info MAIN_ISO_PATH_COUNT; extern const Info MAIN_SKYLANDERS_PATH; std::vector GetIsoPaths(); -void SetIsoPaths(const std::vector& paths); +void SetIsoPaths(std::span paths); // Main.GBA diff --git a/Source/Core/Core/DSP/DSPCodeUtil.cpp b/Source/Core/Core/DSP/DSPCodeUtil.cpp index 7b9b5d3b0a..33791aec58 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.cpp +++ b/Source/Core/Core/DSP/DSPCodeUtil.cpp @@ -4,6 +4,7 @@ #include "Core/DSP/DSPCodeUtil.h" #include +#include #include #include @@ -35,7 +36,7 @@ bool Assemble(const std::string& text, std::vector& code, bool force) return assembler.Assemble(text, code); } -bool Disassemble(const std::vector& code, bool line_numbers, std::string& text) +bool Disassemble(std::span code, bool line_numbers, std::string& text) { if (code.empty()) return false; @@ -56,7 +57,7 @@ bool Disassemble(const std::vector& code, bool line_numbers, std::string& t // NOTE: This code is called from DSPTool and UnitTests, which do not use the logging system. // Thus, fmt::print is used instead of the log system. -bool Compare(const std::vector& code1, const std::vector& code2) +bool Compare(std::span code1, std::span code2) { if (code1.size() != code2.size()) fmt::print("Size difference! 1={} 2={}\n", code1.size(), code2.size()); @@ -106,7 +107,7 @@ bool Compare(const std::vector& code1, const std::vector& code2) if (code2.size() != code1.size()) { fmt::print("Extra code words:\n"); - const std::vector& longest = code1.size() > code2.size() ? code1 : code2; + const auto longest = code1.size() > code2.size() ? code1 : code2; for (u16 i = min_size; i < longest.size(); i++) { u16 pc = i; @@ -119,7 +120,7 @@ bool Compare(const std::vector& code1, const std::vector& code2) return code1.size() == code2.size() && code1.size() == count_equal; } -std::string CodeToBinaryStringBE(const std::vector& code) +std::string CodeToBinaryStringBE(std::span code) { std::string str(code.size() * 2, '\0'); @@ -153,7 +154,7 @@ std::optional> LoadBinary(const std::string& filename) return std::make_optional(BinaryStringBEToCode(buffer)); } -bool SaveBinary(const std::vector& code, const std::string& filename) +bool SaveBinary(std::span code, const std::string& filename) { const std::string buffer = CodeToBinaryStringBE(code); diff --git a/Source/Core/Core/DSP/DSPCodeUtil.h b/Source/Core/Core/DSP/DSPCodeUtil.h index 14cb673a0e..ca4785e18c 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.h +++ b/Source/Core/Core/DSP/DSPCodeUtil.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include @@ -12,16 +13,16 @@ namespace DSP { bool Assemble(const std::string& text, std::vector& code, bool force = false); -bool Disassemble(const std::vector& code, bool line_numbers, std::string& text); -bool Compare(const std::vector& code1, const std::vector& code2); +bool Disassemble(std::span code, bool line_numbers, std::string& text); +bool Compare(std::span code1, std::span code2); // Big-endian, for writing straight to file using File::WriteStringToFile. -std::string CodeToBinaryStringBE(const std::vector& code); +std::string CodeToBinaryStringBE(std::span code); std::vector BinaryStringBEToCode(const std::string& str); // Load code (big endian binary). std::optional> LoadBinary(const std::string& filename); -bool SaveBinary(const std::vector& code, const std::string& filename); +bool SaveBinary(std::span code, const std::string& filename); bool DumpDSPCode(const u8* code_be, size_t size_in_bytes, u32 crc); } // namespace DSP diff --git a/Source/Core/Core/DSP/DSPDisassembler.cpp b/Source/Core/Core/DSP/DSPDisassembler.cpp index 75f235b38f..912b41d579 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.cpp +++ b/Source/Core/Core/DSP/DSPDisassembler.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include @@ -23,7 +22,7 @@ DSPDisassembler::DSPDisassembler(const AssemblerSettings& settings) : settings_( { } -bool DSPDisassembler::Disassemble(const std::vector& code, std::string& text) +bool DSPDisassembler::Disassemble(std::span code, std::string& text) { if (code.size() > std::numeric_limits::max()) { @@ -140,7 +139,7 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1 return buf; } -bool DSPDisassembler::DisassembleOpcode(const std::vector& code, u16* pc, std::string& dest) +bool DSPDisassembler::DisassembleOpcode(std::span code, u16* pc, std::string& dest) { return DisassembleOpcode(code.data(), code.size(), pc, dest); } diff --git a/Source/Core/Core/DSP/DSPDisassembler.h b/Source/Core/Core/DSP/DSPDisassembler.h index 294cc8df52..ca912c5c42 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.h +++ b/Source/Core/Core/DSP/DSPDisassembler.h @@ -4,8 +4,8 @@ #pragma once +#include #include -#include #include "Common/CommonTypes.h" @@ -32,11 +32,11 @@ class DSPDisassembler public: explicit DSPDisassembler(const AssemblerSettings& settings); - bool Disassemble(const std::vector& code, std::string& text); + bool Disassemble(std::span code, std::string& text); // Disassembles the given opcode at pc and increases pc by the opcode's size. // The PC is wrapped such that 0x0000 and 0x8000 both point to the start of the buffer. - bool DisassembleOpcode(const std::vector& code, u16* pc, std::string& dest); + bool DisassembleOpcode(std::span code, u16* pc, std::string& dest); bool DisassembleOpcode(const u16* binbuf, size_t binbuf_size, u16* pc, std::string& dest); private: diff --git a/Source/Core/Core/Debugger/DebugInterface.h b/Source/Core/Core/Debugger/DebugInterface.h index 607cbe8bba..6510dfcddf 100644 --- a/Source/Core/Core/Debugger/DebugInterface.h +++ b/Source/Core/Core/Debugger/DebugInterface.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -40,7 +41,7 @@ public: virtual void DisableWatch(std::size_t index) = 0; virtual bool HasEnabledWatch(u32 address) const = 0; virtual void RemoveWatch(std::size_t index) = 0; - virtual void LoadWatchesFromStrings(const std::vector& watches) = 0; + virtual void LoadWatchesFromStrings(std::span watches) = 0; virtual std::vector SaveWatchesToStrings() const = 0; virtual void ClearWatches() = 0; diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index fd105df2b4..bbb467c4ca 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -158,7 +158,7 @@ void PPCDebugInterface::RemoveWatch(std::size_t index) return m_watches.RemoveWatch(index); } -void PPCDebugInterface::LoadWatchesFromStrings(const std::vector& watches) +void PPCDebugInterface::LoadWatchesFromStrings(std::span watches) { m_watches.LoadFromStrings(watches); } diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index 61f0dedfb3..be116de9cc 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -65,7 +65,7 @@ public: void DisableWatch(std::size_t index) override; bool HasEnabledWatch(u32 address) const override; void RemoveWatch(std::size_t index) override; - void LoadWatchesFromStrings(const std::vector& watches) override; + void LoadWatchesFromStrings(std::span watches) override; std::vector SaveWatchesToStrings() const override; void ClearWatches() override; diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp index 5c30081393..f795d5f08a 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp @@ -389,8 +389,7 @@ bool FifoDataFile::GetFlag(u32 flag) const return !!(m_Flags & flag); } -u64 FifoDataFile::WriteMemoryUpdates(const std::vector& memUpdates, - File::IOFile& file) +u64 FifoDataFile::WriteMemoryUpdates(std::span memUpdates, File::IOFile& file) { // Add space for memory update list u64 updateListOffset = file.Tell(); diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.h b/Source/Core/Core/FifoPlayer/FifoDataFile.h index f0fd098eaa..6aff6d37ba 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.h +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -92,7 +93,7 @@ private: void SetFlag(u32 flag, bool set); bool GetFlag(u32 flag) const; - u64 WriteMemoryUpdates(const std::vector& memUpdates, File::IOFile& file); + u64 WriteMemoryUpdates(std::span memUpdates, File::IOFile& file); static void ReadMemoryUpdates(u64 fileOffset, u32 numUpdates, std::vector& memUpdates, File::IOFile& file); diff --git a/Source/Core/Core/GeckoCodeConfig.cpp b/Source/Core/Core/GeckoCodeConfig.cpp index 46e719b724..edc94ff10d 100644 --- a/Source/Core/Core/GeckoCodeConfig.cpp +++ b/Source/Core/Core/GeckoCodeConfig.cpp @@ -231,7 +231,7 @@ static void SaveGeckoCode(std::vector& lines, const GeckoCode& gcod lines.push_back('*' + note); } -void SaveCodes(Common::IniFile& inifile, const std::vector& gcodes) +void SaveCodes(Common::IniFile& inifile, std::span gcodes) { std::vector lines; std::vector enabled_lines; diff --git a/Source/Core/Core/GeckoCodeConfig.h b/Source/Core/Core/GeckoCodeConfig.h index 8020d83c1e..860eb4dbee 100644 --- a/Source/Core/Core/GeckoCodeConfig.h +++ b/Source/Core/Core/GeckoCodeConfig.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -19,7 +20,7 @@ namespace Gecko { std::vector LoadCodes(const Common::IniFile& globalIni, const Common::IniFile& localIni); std::expected, int> DownloadCodes(std::string gametdb_id); -void SaveCodes(Common::IniFile& inifile, const std::vector& gcodes); +void SaveCodes(Common::IniFile& inifile, std::span gcodes); std::optional DeserializeLine(const std::string& line); } // namespace Gecko diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index 376aeb4add..e7b3401f96 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -133,7 +133,7 @@ void DVDInterface::DoState(PointerWrap& p) } size_t DVDInterface::ProcessDTKSamples(s16* target_samples, size_t target_block_count, - const std::vector& audio_data) + std::span audio_data) { const size_t block_count_to_process = std::min(target_block_count, audio_data.size() / StreamADPCM::ONE_BLOCK_SIZE); @@ -192,7 +192,7 @@ u32 DVDInterface::AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process) } void DVDInterface::DTKStreamingCallback(DIInterruptType interrupt_type, - const std::vector& audio_data, s64 cycles_late) + std::span audio_data, s64 cycles_late) { auto& ai = m_system.GetAudioInterface(); @@ -1305,7 +1305,7 @@ void DVDInterface::SetDriveError(DriveError error) } void DVDInterface::FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, - s64 cycles_late, const std::vector& data) + s64 cycles_late, std::span data) { // The data parameter contains the requested data iff this was called from DVDThread, and is // empty otherwise. DVDThread is the only source of ReplyType::NoReply and ReplyType::DTK. diff --git a/Source/Core/Core/HW/DVD/DVDInterface.h b/Source/Core/Core/HW/DVD/DVDInterface.h index 600edc5050..2e3c562e1d 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.h +++ b/Source/Core/Core/HW/DVD/DVDInterface.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -170,17 +171,17 @@ public: // Used by DVDThread void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, s64 cycles_late, - const std::vector& data = std::vector()); + std::span data = {}); // Used by IOS HLE void SetInterruptEnabled(DIInterruptType interrupt, bool enabled); void ClearInterrupt(DIInterruptType interrupt); private: - void DTKStreamingCallback(DIInterruptType interrupt_type, const std::vector& audio_data, + void DTKStreamingCallback(DIInterruptType interrupt_type, std::span audio_data, s64 cycles_late); size_t ProcessDTKSamples(s16* target_samples, size_t target_block_count, - const std::vector& audio_data); + const std::span audio_data); u32 AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process); void SetLidOpen(); diff --git a/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp b/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp index ed9cd5b488..9a96c2bdb5 100644 --- a/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp +++ b/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp @@ -124,9 +124,9 @@ bool CEXIETHERNET::BuiltInBBAInterface::IsActivated() return m_active; } -void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(const std::vector& data) +void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(std::vector data) { - m_queue_data[m_queue_write] = data; + m_queue_data[m_queue_write] = std::move(data); const u8 next_write_index = (m_queue_write + 1) & 15; if (next_write_index != m_queue_read) m_queue_write = next_write_index; @@ -178,7 +178,7 @@ void CEXIETHERNET::BuiltInBBAInterface::PollData(std::size_t* datasize) // Otherwise, enqueue it const auto socket_data = TryGetDataFromSocket(&net_ref); if (socket_data.has_value()) - WriteToQueue(*socket_data); + WriteToQueue(std::move(*socket_data)); } else { @@ -220,7 +220,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleDHCP(const Common::UDPPacket& pack const u8* router_ip_ptr = reinterpret_cast(&m_router_ip); const std::vector ip_part(router_ip_ptr, router_ip_ptr + sizeof(m_router_ip)); - const std::vector timeout_24h = {0, 1, 0x51, 0x80}; + constexpr auto timeout_24h = std::to_array({0, 1, 0x51, 0x80}); Common::DHCPPacket reply; reply.body = Common::DHCPBody(request.transaction_id, m_current_mac, m_current_ip, m_router_ip); @@ -666,8 +666,7 @@ bool CEXIETHERNET::BuiltInBBAInterface::SendFrame(const u8* frame, u32 size) case IPPROTO_IGMP: { // Acknowledge IGMP packet - const std::vector data(frame, frame + size); - WriteToQueue(data); + WriteToQueue({frame, frame + size}); break; } diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h index 78b20f5a44..00d0fcb84e 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h @@ -463,7 +463,7 @@ private: Common::Flag m_read_thread_shutdown; static void ReadThreadHandler(BuiltInBBAInterface* self); #endif - void WriteToQueue(const std::vector& data); + void WriteToQueue(std::vector data); bool WillQueueOverrun() const; void PollData(std::size_t* datasize); std::optional> TryGetDataFromSocket(StackRef* ref); diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index 60287424d5..e6d8fd56a5 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -369,7 +369,7 @@ bool MemoryManager::TryAddLargePageTableMapping(u32 logical_address, u32 transla return CanCreateHostMappingForGuestPages(entries); } -bool MemoryManager::CanCreateHostMappingForGuestPages(const std::vector& entries) const +bool MemoryManager::CanCreateHostMappingForGuestPages(std::span entries) const { const u32 translated_address = entries[0]; if ((translated_address & (m_page_size - 1)) != 0) diff --git a/Source/Core/Core/HW/Memmap.h b/Source/Core/Core/HW/Memmap.h index 421fc32e0b..baa910cc70 100644 --- a/Source/Core/Core/HW/Memmap.h +++ b/Source/Core/Core/HW/Memmap.h @@ -289,7 +289,7 @@ private: void TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool writeable); bool TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, std::map>& map); - bool CanCreateHostMappingForGuestPages(const std::vector& entries) const; + bool CanCreateHostMappingForGuestPages(std::span entries) const; void AddHostPageTableMapping(u32 logical_address, u32 translated_address, bool writeable, u32 logical_size); void RemoveLargePageTableMapping(u32 logical_address); diff --git a/Source/Core/Core/HW/WiiSave.cpp b/Source/Core/Core/HW/WiiSave.cpp index 051a0a8936..1c3e676897 100644 --- a/Source/Core/Core/HW/WiiSave.cpp +++ b/Source/Core/Core/HW/WiiSave.cpp @@ -158,7 +158,7 @@ public: bool WriteBkHeader(const BkHeader& bk_header) override { return true; } - bool WriteFiles(const std::vector& files) override + bool WriteFiles(std::span files) override { if (!m_uid || !m_gid) return false; @@ -390,7 +390,7 @@ public: return m_file.Seek(sizeof(Header), File::SeekOrigin::Begin) && m_file.WriteArray(&bk_header, 1); } - bool WriteFiles(const std::vector& files) override + bool WriteFiles(std::span files) override { if (!m_file.Seek(sizeof(Header) + sizeof(BkHeader), File::SeekOrigin::Begin)) return false; diff --git a/Source/Core/Core/HW/WiiSaveStructs.h b/Source/Core/Core/HW/WiiSaveStructs.h index e95ce0b6fa..dd4c18df50 100644 --- a/Source/Core/Core/HW/WiiSaveStructs.h +++ b/Source/Core/Core/HW/WiiSaveStructs.h @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -108,6 +109,6 @@ public: virtual std::optional> ReadFiles() = 0; virtual bool WriteHeader(const Header& header) = 0; virtual bool WriteBkHeader(const BkHeader& bk_header) = 0; - virtual bool WriteFiles(const std::vector& files) = 0; + virtual bool WriteFiles(std::span files) = 0; }; } // namespace WiiSave diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index 2c19e99f4c..576395059c 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include @@ -36,7 +37,7 @@ class GBAHostInterface public: virtual ~GBAHostInterface() = default; virtual void GameChanged() = 0; - virtual void FrameEnded(const std::vector& video_buffer) = 0; + virtual void FrameEnded(std::span video_buffer) = 0; }; enum class HostMessageID diff --git a/Source/Core/Core/IOS/ES/ES.h b/Source/Core/Core/IOS/ES/ES.h index e5c9f4f06a..ec6adb4856 100644 --- a/Source/Core/Core/IOS/ES/ES.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -4,7 +4,7 @@ #pragma once #include -#include +#include #include #include @@ -376,8 +376,8 @@ private: IPCReply SeekContent(u32 uid, const IOCtlVRequest& request); // Title information - IPCReply GetTitleCount(const std::vector& titles, const IOCtlVRequest& request); - IPCReply GetTitles(const std::vector& titles, const IOCtlVRequest& request); + IPCReply GetTitleCount(std::span titles, const IOCtlVRequest& request); + IPCReply GetTitles(std::span titles, const IOCtlVRequest& request); IPCReply GetOwnedTitleCount(const IOCtlVRequest& request); IPCReply GetOwnedTitles(const IOCtlVRequest& request); IPCReply GetTitleCount(const IOCtlVRequest& request); @@ -416,7 +416,7 @@ private: void FinishInit(); - s32 WriteSystemFile(const std::string& path, const std::vector& data, Ticks ticks = {}); + s32 WriteSystemFile(const std::string& path, std::span data, Ticks ticks = {}); s32 WriteLaunchFile(const ES::TMDReader& tmd, Ticks ticks = {}); bool BootstrapPPC(); diff --git a/Source/Core/Core/IOS/ES/NandUtils.cpp b/Source/Core/Core/IOS/ES/NandUtils.cpp index ee26f37e14..9215d93fd9 100644 --- a/Source/Core/Core/IOS/ES/NandUtils.cpp +++ b/Source/Core/Core/IOS/ES/NandUtils.cpp @@ -399,7 +399,7 @@ std::string ESCore::GetContentPath(const u64 title_id, const ES::Content& conten return fmt::format("{}/{:08x}.app", Common::GetTitleContentPath(title_id), content.id); } -s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector& data, Ticks ticks) +s32 ESDevice::WriteSystemFile(const std::string& path, std::span data, Ticks ticks) { auto& fs = GetEmulationKernel().GetFSCore(); const std::string tmp_path = "/tmp/" + PathToFileName(path); diff --git a/Source/Core/Core/IOS/ES/TitleInformation.cpp b/Source/Core/Core/IOS/ES/TitleInformation.cpp index 4e312505f7..88096c4f19 100644 --- a/Source/Core/Core/IOS/ES/TitleInformation.cpp +++ b/Source/Core/Core/IOS/ES/TitleInformation.cpp @@ -120,7 +120,7 @@ IPCReply ESDevice::GetTMDStoredContents(const IOCtlVRequest& request) return GetStoredContents(tmd, request); } -IPCReply ESDevice::GetTitleCount(const std::vector& titles, const IOCtlVRequest& request) +IPCReply ESDevice::GetTitleCount(std::span titles, const IOCtlVRequest& request) { if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 4) return IPCReply(ES_EINVAL); @@ -132,7 +132,7 @@ IPCReply ESDevice::GetTitleCount(const std::vector& titles, const IOCtlVReq return IPCReply(IPC_SUCCESS); } -IPCReply ESDevice::GetTitles(const std::vector& titles, const IOCtlVRequest& request) +IPCReply ESDevice::GetTitles(std::span titles, const IOCtlVRequest& request) { if (!request.HasNumberOfValidVectors(1, 1)) return IPCReply(ES_EINVAL); diff --git a/Source/Core/Core/IOS/ES/TitleManagement.cpp b/Source/Core/Core/IOS/ES/TitleManagement.cpp index eca3a43ac6..9750c5a0aa 100644 --- a/Source/Core/Core/IOS/ES/TitleManagement.cpp +++ b/Source/Core/Core/IOS/ES/TitleManagement.cpp @@ -372,7 +372,7 @@ IPCReply ESDevice::ImportContentData(Context& context, const IOCtlVRequest& requ return IPCReply(m_core.ImportContentData(context, content_fd, data_start, data_size)); } -static bool CheckIfContentHashMatches(const std::vector& content, const ES::Content& info) +static bool CheckIfContentHashMatches(std::span content, const ES::Content& info) { return Common::SHA1::CalculateDigest(content.data(), info.size) == info.sha1; } diff --git a/Source/Core/Core/IOS/WFS/WFSI.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp index 566956832a..c037967d6a 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.cpp +++ b/Source/Core/Core/IOS/WFS/WFSI.cpp @@ -43,7 +43,7 @@ void ARCUnpacker::Reset() m_whole_file.clear(); } -void ARCUnpacker::AddBytes(const std::vector& bytes) +void ARCUnpacker::AddBytes(std::span bytes) { m_whole_file.insert(m_whole_file.end(), bytes.begin(), bytes.end()); } @@ -244,7 +244,7 @@ std::optional WFSIDevice::IOCtl(const IOCtlRequest& request) "IOCTL_WFSI_IMPORT_CONTENT_END"; INFO_LOG_FMT(IOS_WFS, "{}", ioctl_name); - const auto callback = [this](const std::string& filename, const std::vector& bytes) { + const auto callback = [this](const std::string& filename, std::span bytes) { INFO_LOG_FMT(IOS_WFS, "Extract: {} ({} bytes)", filename, bytes.size()); const std::string path = WFS::NativePath(m_base_extract_path + '/' + filename); diff --git a/Source/Core/Core/IOS/WFS/WFSI.h b/Source/Core/Core/IOS/WFS/WFSI.h index 4ab92df39e..19d3565660 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.h +++ b/Source/Core/Core/IOS/WFS/WFSI.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -22,9 +23,9 @@ public: ARCUnpacker() { Reset(); } void Reset(); - void AddBytes(const std::vector& bytes); + void AddBytes(std::span bytes); - using WriteCallback = std::function&)>; + using WriteCallback = std::function)>; void Extract(const WriteCallback& callback); private: diff --git a/Source/Core/Core/NetPlayClient.h b/Source/Core/Core/NetPlayClient.h index d5675ee63e..0a0dd6267e 100644 --- a/Source/Core/Core/NetPlayClient.h +++ b/Source/Core/Core/NetPlayClient.h @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "Common/CommonTypes.h" @@ -89,7 +88,7 @@ public: virtual void OnIndexRefreshFailed(std::string error) = 0; virtual void ShowChunkedProgressDialog(const std::string& title, u64 data_size, - const std::vector& players) = 0; + std::span players) = 0; virtual void HideChunkedProgressDialog() = 0; virtual void SetChunkedProgress(int pid, u64 progress) = 0; diff --git a/Source/Core/Core/NetPlayCommon.cpp b/Source/Core/Core/NetPlayCommon.cpp index 91a03dd63e..053a7533a9 100644 --- a/Source/Core/Core/NetPlayCommon.cpp +++ b/Source/Core/Core/NetPlayCommon.cpp @@ -116,7 +116,7 @@ bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet return CompressFolderIntoPacketInternal(File::ScanDirectoryTree(folder_path, true), packet); } -bool CompressBufferIntoPacket(const std::vector& in_buffer, sf::Packet& packet) +bool CompressBufferIntoPacket(std::span in_buffer, sf::Packet& packet) { const u64 size = in_buffer.size(); packet << size; diff --git a/Source/Core/Core/NetPlayCommon.h b/Source/Core/Core/NetPlayCommon.h index a777728ac2..0c95b49c2d 100644 --- a/Source/Core/Core/NetPlayCommon.h +++ b/Source/Core/Core/NetPlayCommon.h @@ -5,9 +5,9 @@ #include -#include #include #include +#include #include #include @@ -22,7 +22,7 @@ constexpr std::chrono::milliseconds PEER_TIMEOUT = 30s; bool CompressFileIntoPacket(const std::string& file_path, sf::Packet& packet); bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet); -bool CompressBufferIntoPacket(const std::vector& in_buffer, sf::Packet& packet); +bool CompressBufferIntoPacket(std::span in_buffer, sf::Packet& packet); bool DecompressPacketIntoFile(sf::Packet& packet, const std::string& file_path); bool DecompressPacketIntoFolder(sf::Packet& packet, const std::string& folder_path); std::optional> DecompressPacketIntoBuffer(sf::Packet& packet); diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index 8ac96bb3f9..ca51b52a3a 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -149,7 +149,7 @@ void LoadPatchSection(const std::string& section, std::vector* patches, } } -void SavePatchSection(Common::IniFile* local_ini, const std::vector& patches) +void SavePatchSection(Common::IniFile* local_ini, std::span patches) { std::vector lines; std::vector lines_enabled; diff --git a/Source/Core/Core/PatchEngine.h b/Source/Core/Core/PatchEngine.h index 32e4ec93db..7acff8689b 100644 --- a/Source/Core/Core/PatchEngine.h +++ b/Source/Core/Core/PatchEngine.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include @@ -53,7 +54,7 @@ std::optional DeserializeLine(std::string line); std::string SerializeLine(const PatchEntry& entry); void LoadPatchSection(const std::string& section, std::vector* patches, const Common::IniFile& globalIni, const Common::IniFile& localIni); -void SavePatchSection(Common::IniFile* local_ini, const std::vector& patches); +void SavePatchSection(Common::IniFile* local_ini, std::span patches); void LoadPatches(); void AddMemoryPatch(std::size_t index); diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index fa6544d61b..ffc54cad9b 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -267,7 +267,7 @@ struct SlotWithTimestamp } // namespace // Returns first slot number (1-based indexing) not in the vector. -static std::optional GetEmptySlot(const std::vector& used_slots) +static std::optional GetEmptySlot(std::span used_slots) { for (int i = 1; i <= int(NUM_STATES); ++i) { diff --git a/Source/Core/Core/WiiUtils.cpp b/Source/Core/Core/WiiUtils.cpp index 3ac5e222cf..8431b5de84 100644 --- a/Source/Core/Core/WiiUtils.cpp +++ b/Source/Core/Core/WiiUtils.cpp @@ -346,7 +346,7 @@ private: }; Response GetSystemTitles(); - Response ParseTitlesResponse(const std::vector& response) const; + Response ParseTitlesResponse(std::span response) const; bool ShouldInstallTitle(const TitleInfo& title); UpdateResult InstallTitleFromNUS(const std::string& prefix_url, const TitleInfo& title, @@ -371,7 +371,7 @@ OnlineSystemUpdater::OnlineSystemUpdater(UpdateCallback update_callback, const s } OnlineSystemUpdater::Response -OnlineSystemUpdater::ParseTitlesResponse(const std::vector& response) const +OnlineSystemUpdater::ParseTitlesResponse(std::span response) const { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_buffer(response.data(), response.size()); diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index 11acc8eb41..fe6c3880df 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -575,7 +575,7 @@ u64 DirectoryBlobReader::GetDataSize() const return m_data_size; } -void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(const std::vector& partition_header, +void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(std::span partition_header, const std::string& game_partition_root) { std::vector header_bin(WII_NONPARTITION_DISCHEADER_SIZE); @@ -585,7 +585,7 @@ void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(const std::vector& partition_header, +void DirectoryBlobReader::SetNonpartitionDiscHeader(std::span partition_header, std::vector header_bin) { const size_t header_bin_size = header_bin.size(); @@ -619,7 +619,7 @@ void DirectoryBlobReader::SetWiiRegionDataFromFile(const std::string& game_parti SetWiiRegionData(wii_region_data, region_bin_path); } -void DirectoryBlobReader::SetWiiRegionData(const std::vector& wii_region_data, +void DirectoryBlobReader::SetWiiRegionData(std::span wii_region_data, const std::string& log_path) { std::vector region_data(0x10, 0x00); @@ -961,7 +961,7 @@ DirectoryBlobPartition::DirectoryBlobPartition( } void DirectoryBlobPartition::SetDiscType(std::optional is_wii, - const std::vector& disc_header) + std::span disc_header) { if (is_wii.has_value()) { @@ -1108,7 +1108,7 @@ static void ConvertUTF8NamesToSHIFTJIS(std::vector* fst) } } -static u32 ComputeNameSize(const std::vector& files) +static u32 ComputeNameSize(std::span files) { u32 name_size = 0; for (const FSTBuilderNode& entry : files) diff --git a/Source/Core/DiscIO/DirectoryBlob.h b/Source/Core/DiscIO/DirectoryBlob.h index 01cb5d1606..9ee3e36fc6 100644 --- a/Source/Core/DiscIO/DirectoryBlob.h +++ b/Source/Core/DiscIO/DirectoryBlob.h @@ -200,7 +200,7 @@ public: void SetKey(std::array key) { m_key = key; } private: - void SetDiscType(std::optional is_wii, const std::vector& disc_header); + void SetDiscType(std::optional is_wii, std::span disc_header); void SetBI2FromFile(const std::string& bi2_path); void SetBI2(std::vector bi2); @@ -296,12 +296,11 @@ private: bool EncryptPartitionData(u64 offset, u64 size, u8* buffer, u64 partition_data_offset, u64 partition_data_decrypted_size); - void SetNonpartitionDiscHeaderFromFile(const std::vector& partition_header, + void SetNonpartitionDiscHeaderFromFile(std::span partition_header, const std::string& game_partition_root); - void SetNonpartitionDiscHeader(const std::vector& partition_header, - std::vector header_bin); + void SetNonpartitionDiscHeader(std::span partition_header, std::vector header_bin); void SetWiiRegionDataFromFile(const std::string& game_partition_root); - void SetWiiRegionData(const std::vector& wii_region_data, const std::string& log_path); + void SetWiiRegionData(std::span wii_region_data, const std::string& log_path); void SetPartitions(std::vector&& partitions); void SetPartitionHeader(DirectoryBlobPartition* partition, u64 partition_address); diff --git a/Source/Core/DiscIO/DiscUtils.cpp b/Source/Core/DiscIO/DiscUtils.cpp index a22b97a466..e068229e57 100644 --- a/Source/Core/DiscIO/DiscUtils.cpp +++ b/Source/Core/DiscIO/DiscUtils.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -155,7 +156,7 @@ static u64 GetBiggestReferencedOffset(const Volume& volume, const FileInfo& file } } -u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector& partitions) +u64 GetBiggestReferencedOffset(const Volume& volume, std::span partitions) { const u64 disc_header_size = volume.GetVolumeType() == Platform::GameCubeDisc ? 0x460 : 0x50000; u64 biggest_offset = disc_header_size; diff --git a/Source/Core/DiscIO/DiscUtils.h b/Source/Core/DiscIO/DiscUtils.h index 805a1a476b..9a467b8ea6 100644 --- a/Source/Core/DiscIO/DiscUtils.h +++ b/Source/Core/DiscIO/DiscUtils.h @@ -4,8 +4,8 @@ #pragma once #include +#include #include -#include #include "Common/CommonTypes.h" #include "DiscIO/Blob.h" @@ -84,7 +84,7 @@ std::optional GetFSTOffset(const Volume& volume, const Partition& partition std::optional GetFSTSize(const Volume& volume, const Partition& partition); u64 GetBiggestReferencedOffset(const Volume& volume); -u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector& partitions); +u64 GetBiggestReferencedOffset(const Volume& volume, std::span partitions); bool IsGCZBlockSizeLegacyCompatible(int block_size, u64 file_size); bool IsDiscImageBlockSizeValid(int block_size, BlobType format); diff --git a/Source/Core/DiscIO/NFSBlob.cpp b/Source/Core/DiscIO/NFSBlob.cpp index df6a65f321..6e13c70955 100644 --- a/Source/Core/DiscIO/NFSBlob.cpp +++ b/Source/Core/DiscIO/NFSBlob.cpp @@ -105,7 +105,7 @@ std::vector NFSFileReader::OpenFiles(const std::string& dire return files; } -u64 NFSFileReader::CalculateExpectedRawSize(const std::vector& lba_ranges) +u64 NFSFileReader::CalculateExpectedRawSize(std::span lba_ranges) { u64 total_blocks = 0; for (const NFSLBARange& range : lba_ranges) @@ -114,7 +114,7 @@ u64 NFSFileReader::CalculateExpectedRawSize(const std::vector& lba_ return sizeof(NFSHeader) + total_blocks * BLOCK_SIZE; } -u64 NFSFileReader::CalculateExpectedDataSize(const std::vector& lba_ranges) +u64 NFSFileReader::CalculateExpectedDataSize(std::span lba_ranges) { u32 greatest_block_index = 0; for (const NFSLBARange& range : lba_ranges) diff --git a/Source/Core/DiscIO/NFSBlob.h b/Source/Core/DiscIO/NFSBlob.h index dcbe6bf31a..0463e46891 100644 --- a/Source/Core/DiscIO/NFSBlob.h +++ b/Source/Core/DiscIO/NFSBlob.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -68,8 +69,8 @@ private: static std::vector OpenFiles(const std::string& directory, File::DirectIOFile first_file, u64 expected_raw_size, u64* raw_size_out); - static u64 CalculateExpectedRawSize(const std::vector& lba_ranges); - static u64 CalculateExpectedDataSize(const std::vector& lba_ranges); + static u64 CalculateExpectedRawSize(std::span lba_ranges); + static u64 CalculateExpectedDataSize(std::span lba_ranges); NFSFileReader(std::vector lba_ranges, std::vector files, Key key, u64 raw_size); diff --git a/Source/Core/DiscIO/RiivolutionParser.cpp b/Source/Core/DiscIO/RiivolutionParser.cpp index c76274927a..079b86e5cc 100644 --- a/Source/Core/DiscIO/RiivolutionParser.cpp +++ b/Source/Core/DiscIO/RiivolutionParser.cpp @@ -218,9 +218,9 @@ std::optional ParseString(std::string_view xml, std::string xml_path) return disc; } -static bool CheckRegion(const std::vector& xml_regions, std::string_view game_region) +static bool CheckRegion(std::span xml_regions, std::string_view game_region) { - if (xml_regions.begin() == xml_regions.end()) + if (xml_regions.empty()) return true; for (const auto& region : xml_regions) diff --git a/Source/Core/DiscIO/Volume.cpp b/Source/Core/DiscIO/Volume.cpp index c1942b2aeb..cbed3acf55 100644 --- a/Source/Core/DiscIO/Volume.cpp +++ b/Source/Core/DiscIO/Volume.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -93,7 +92,7 @@ void Volume::AddTMDToSyncHash(Common::SHA1::Context* context, const Partition& p AddToSyncHash(context, content); } -std::map Volume::ReadWiiNames(const std::vector& data) +std::map Volume::ReadWiiNames(std::span data) { std::map names; for (size_t i = 0; i < NUMBER_OF_LANGUAGES; ++i) diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h index a001c60c85..7dfabb3e97 100644 --- a/Source/Core/DiscIO/Volume.h +++ b/Source/Core/DiscIO/Volume.h @@ -81,7 +81,7 @@ public: virtual std::vector GetContent(u16 index) const { return {}; } virtual std::vector GetContentOffsets() const { return {}; } virtual bool CheckContentIntegrity(const IOS::ES::Content& content, - const std::vector& encrypted_data, + std::span encrypted_data, const IOS::ES::TicketReader& ticket) const { return false; @@ -150,7 +150,7 @@ protected: void AddTMDToSyncHash(Common::SHA1::Context* context, const Partition& partition) const; virtual u32 GetOffsetShift() const { return 0; } - static std::map ReadWiiNames(const std::vector& data); + static std::map ReadWiiNames(std::span data); static constexpr size_t NUMBER_OF_LANGUAGES = 10; static constexpr size_t NAME_CHARS_LENGTH = 42; diff --git a/Source/Core/DiscIO/VolumeVerifier.cpp b/Source/Core/DiscIO/VolumeVerifier.cpp index 7fd4ce2768..9ffeb63757 100644 --- a/Source/Core/DiscIO/VolumeVerifier.cpp +++ b/Source/Core/DiscIO/VolumeVerifier.cpp @@ -213,7 +213,7 @@ static std::vector ParseHash(const char* str) return hash; } -std::vector RedumpVerifier::ScanDatfile(const std::vector& data, +std::vector RedumpVerifier::ScanDatfile(std::span data, const std::string& system) { pugi::xml_document doc; diff --git a/Source/Core/DiscIO/VolumeVerifier.h b/Source/Core/DiscIO/VolumeVerifier.h index 7a5c342e1b..bb814f8b4d 100644 --- a/Source/Core/DiscIO/VolumeVerifier.h +++ b/Source/Core/DiscIO/VolumeVerifier.h @@ -85,7 +85,7 @@ private: static DownloadStatus DownloadDatfile(const std::string& system, DownloadStatus old_status); static std::vector ReadDatfile(const std::string& system); - std::vector ScanDatfile(const std::vector& data, const std::string& system); + std::vector ScanDatfile(std::span data, const std::string& system); std::string m_game_id; u16 m_revision = 0; diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 44e229e1ce..95c6a68dc6 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -149,7 +150,7 @@ std::vector VolumeWAD::GetContentOffsets() const } bool VolumeWAD::CheckContentIntegrity(const IOS::ES::Content& content, - const std::vector& encrypted_data, + std::span encrypted_data, const IOS::ES::TicketReader& ticket) const { if (encrypted_data.size() != Common::AlignUp(content.size, 0x40)) diff --git a/Source/Core/DiscIO/VolumeWad.h b/Source/Core/DiscIO/VolumeWad.h index a5d843eed4..2c383c0254 100644 --- a/Source/Core/DiscIO/VolumeWad.h +++ b/Source/Core/DiscIO/VolumeWad.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -38,7 +39,7 @@ public: GetCertificateChain(const Partition& partition = PARTITION_NONE) const override; std::vector GetContent(u16 index) const override; std::vector GetContentOffsets() const override; - bool CheckContentIntegrity(const IOS::ES::Content& content, const std::vector& encrypted_data, + bool CheckContentIntegrity(const IOS::ES::Content& content, std::span encrypted_data, const IOS::ES::TicketReader& ticket) const override; IOS::ES::TicketReader GetTicketWithFixedCommonKey() const override; std::string GetGameID(const Partition& partition = PARTITION_NONE) const override; diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp index 31000deb02..3f7b274ca8 100644 --- a/Source/Core/DiscIO/WIABlob.cpp +++ b/Source/Core/DiscIO/WIABlob.cpp @@ -860,7 +860,7 @@ size_t WIARVZFileReader::Chunk::GetOutBytesWrittenExcludingExceptions() con template bool WIARVZFileReader::ApplyHashExceptions( - const std::vector& exception_list, + std::span exception_list, VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP]) { for (const HashExceptionEntry& exception : exception_list) diff --git a/Source/Core/DiscIO/WIABlob.h b/Source/Core/DiscIO/WIABlob.h index 96ef455fcb..cb9acaa1a5 100644 --- a/Source/Core/DiscIO/WIABlob.h +++ b/Source/Core/DiscIO/WIABlob.h @@ -242,7 +242,7 @@ private: WIARVZCompressionType compression_type, u32 exception_lists = 0, u32 rvz_packed_size = 0, u64 data_offset = 0); - static bool ApplyHashExceptions(const std::vector& exception_list, + static bool ApplyHashExceptions(std::span exception_list, VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP]); static std::string VersionToString(u32 version); diff --git a/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp b/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp index bdc9518587..60633b010f 100644 --- a/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp +++ b/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp @@ -45,7 +45,7 @@ void ConfigChoiceU32::OnConfigChanged() setCurrentIndex(ReadValue(m_setting)); } -ConfigStringChoice::ConfigStringChoice(const std::vector& options, +ConfigStringChoice::ConfigStringChoice(std::span options, const Config::Info& setting, Config::Layer* layer) : ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(true) @@ -57,7 +57,7 @@ ConfigStringChoice::ConfigStringChoice(const std::vector& options, connect(this, &QComboBox::currentIndexChanged, this, &ConfigStringChoice::Update); } -ConfigStringChoice::ConfigStringChoice(const std::vector>& options, +ConfigStringChoice::ConfigStringChoice(std::span> options, const Config::Info& setting, Config::Layer* layer) : ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(false) diff --git a/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.h b/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.h index 40f7bdccbe..46902e513a 100644 --- a/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.h +++ b/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.h @@ -85,9 +85,9 @@ class ConfigStringChoice final : public ConfigControl { Q_OBJECT public: - ConfigStringChoice(const std::vector& options, - const Config::Info& setting, Config::Layer* layer = nullptr); - ConfigStringChoice(const std::vector>& options, + ConfigStringChoice(std::span options, const Config::Info& setting, + Config::Layer* layer = nullptr); + ConfigStringChoice(std::span> options, const Config::Info& setting, Config::Layer* layer = nullptr); void Load(); diff --git a/Source/Core/DolphinQt/Config/VerifyWidget.cpp b/Source/Core/DolphinQt/Config/VerifyWidget.cpp index 42835fd673..b95a4ac269 100644 --- a/Source/Core/DolphinQt/Config/VerifyWidget.cpp +++ b/Source/Core/DolphinQt/Config/VerifyWidget.cpp @@ -6,8 +6,8 @@ #include #include #include +#include #include -#include #include #include @@ -129,7 +129,7 @@ void VerifyWidget::ConnectWidgets() #endif } -static void SetHash(QLineEdit* line_edit, const std::vector& hash) +static void SetHash(QLineEdit* line_edit, std::span hash) { const QByteArray byte_array = QByteArray::fromRawData(reinterpret_cast(hash.data()), static_cast(hash.size())); diff --git a/Source/Core/DolphinQt/Config/VerifyWidget.h b/Source/Core/DolphinQt/Config/VerifyWidget.h index c2b2868d74..5a00efb013 100644 --- a/Source/Core/DolphinQt/Config/VerifyWidget.h +++ b/Source/Core/DolphinQt/Config/VerifyWidget.h @@ -4,7 +4,6 @@ #pragma once #include -#include #include #include diff --git a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp index 260d51b9af..29b431d292 100644 --- a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp +++ b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp @@ -98,7 +98,7 @@ void WiimoteControllersWidget::StartBluetoothAdapterRefresh() } void WiimoteControllersWidget::OnBluetoothAdapterRefreshComplete( - const std::vector& devices) + std::span devices) { const int configured_vid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID); const int configured_pid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID); diff --git a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.h b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.h index b2a082b3e2..6903d9eab3 100644 --- a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.h +++ b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include @@ -40,7 +41,7 @@ private: void OnBluetoothPassthroughDeviceChanged(int index); void OnBluetoothPassthroughSyncPressed(); void OnBluetoothPassthroughResetPressed(); - void OnBluetoothAdapterRefreshComplete(const std::vector& devices); + void OnBluetoothAdapterRefreshComplete(std::span devices); void OnWiimoteRefreshPressed(); void OnWiimoteConfigure(size_t index); void StartBluetoothAdapterRefresh(); diff --git a/Source/Core/DolphinQt/GBAHost.cpp b/Source/Core/DolphinQt/GBAHost.cpp index 453ae67460..847433e0f3 100644 --- a/Source/Core/DolphinQt/GBAHost.cpp +++ b/Source/Core/DolphinQt/GBAHost.cpp @@ -38,7 +38,7 @@ void GBAHost::GameChanged() }); } -void GBAHost::FrameEnded(const std::vector& video_buffer) +void GBAHost::FrameEnded(std::span video_buffer) { QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, video_buffer] { widget_controller->FrameEnded(video_buffer); diff --git a/Source/Core/DolphinQt/GBAHost.h b/Source/Core/DolphinQt/GBAHost.h index da8c6660ab..a2f4aeab10 100644 --- a/Source/Core/DolphinQt/GBAHost.h +++ b/Source/Core/DolphinQt/GBAHost.h @@ -5,7 +5,7 @@ #ifdef HAS_LIBMGBA -#include +#include #include "Core/Host.h" @@ -22,7 +22,7 @@ public: explicit GBAHost(std::weak_ptr core); ~GBAHost() override; void GameChanged() override; - void FrameEnded(const std::vector& video_buffer) override; + void FrameEnded(std::span video_buffer) override; private: GBAWidgetController* m_widget_controller{}; diff --git a/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.cpp b/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.cpp index b24c2563ff..0c69f76597 100644 --- a/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.cpp @@ -65,7 +65,7 @@ void ChunkedProgressDialog::ConnectWidgets() } void ChunkedProgressDialog::show(const QString& title, const u64 data_size, - const std::vector& players) + std::span players) { m_progress_box->setTitle(title); m_data_size = data_size; diff --git a/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.h b/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.h index 0d63e180cc..61dc37212f 100644 --- a/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.h +++ b/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.h @@ -4,7 +4,7 @@ #pragma once #include -#include +#include #include @@ -23,7 +23,7 @@ class ChunkedProgressDialog : public QDialog public: explicit ChunkedProgressDialog(QWidget* parent); - void show(const QString& title, u64 data_size, const std::vector& players); + void show(const QString& title, u64 data_size, std::span players); void SetProgress(int pid, u64 progress); void reject() override; diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp index d50cee2b9a..b71af44161 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp @@ -1248,7 +1248,7 @@ void NetPlayDialog::AbortGameDigest() } void NetPlayDialog::ShowChunkedProgressDialog(const std::string& title, const u64 data_size, - const std::vector& players) + std::span players) { QueueOnObject(this, [this, title, data_size, players] { if (m_chunked_progress_dialog->isVisible()) diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.h b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.h index 8b5da5fa18..54cc111e92 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.h +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.h @@ -93,7 +93,7 @@ public: void AbortGameDigest() override; void ShowChunkedProgressDialog(const std::string& title, u64 data_size, - const std::vector& players) override; + std::span players) override; void HideChunkedProgressDialog() override; void SetChunkedProgress(int pid, u64 progress) override; diff --git a/Source/Core/UICommon/NetPlayIndex.cpp b/Source/Core/UICommon/NetPlayIndex.cpp index f6f3b57754..1d4b5e0b8a 100644 --- a/Source/Core/UICommon/NetPlayIndex.cpp +++ b/Source/Core/UICommon/NetPlayIndex.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -23,14 +24,13 @@ NetPlayIndex::~NetPlayIndex() Remove(); } -static std::optional ParseResponse(const std::vector& response) +static std::optional ParseResponse(std::span response) { - const std::string response_string(reinterpret_cast(response.data()), - response.size()); + const char* data = reinterpret_cast(response.data()); picojson::value json; - const auto error = picojson::parse(json, response_string); + const auto error = picojson::parse(json, data, data + response.size()); if (!error.empty()) return {}; diff --git a/Source/Core/UpdaterCommon/UpdaterCommon.cpp b/Source/Core/UpdaterCommon/UpdaterCommon.cpp index 56f9c7f7e8..0d98f19187 100644 --- a/Source/Core/UpdaterCommon/UpdaterCommon.cpp +++ b/Source/Core/UpdaterCommon/UpdaterCommon.cpp @@ -14,7 +14,9 @@ #include #include +#ifdef _WIN32 #include "Common/CommonFuncs.h" +#endif #include "Common/CommonPaths.h" #include "Common/FileUtil.h" #include "Common/HttpRequest.h" @@ -204,7 +206,7 @@ void TodoList::Log() const } } -static bool DownloadContent(const std::vector& to_download, +static bool DownloadContent(std::span to_download, const std::string& content_base_url, const std::string& temp_path) { Common::HttpRequest req(std::chrono::seconds(30), ProgressCallback); @@ -337,7 +339,7 @@ static bool BackupFile(const std::string& path) return true; } -static bool DeleteObsoleteFiles(const std::vector& to_delete, +static bool DeleteObsoleteFiles(std::span to_delete, const std::string& install_base_path) { for (const auto& op : to_delete) @@ -370,7 +372,7 @@ static bool DeleteObsoleteFiles(const std::vector& to_delete return true; } -static bool UpdateFiles(const std::vector& to_update, +static bool UpdateFiles(std::span to_update, const std::string& install_base_path, const std::string& temp_path) { #ifdef _WIN32 diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 973b944d98..6d69803827 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -161,7 +161,7 @@ bool VertexShaderManager::UseVertexDepthRange() // Syncs the shader constant buffers with xfmem // TODO: A cleaner way to control the matrices without making a mess in the parameters field -void VertexShaderManager::SetConstants(const std::vector& textures, +void VertexShaderManager::SetConstants(std::span textures, XFStateManager& xf_state_manager) { if (constants.missing_color_hex != g_ActiveConfig.iMissingColorValue) diff --git a/Source/Core/VideoCommon/VertexShaderManager.h b/Source/Core/VideoCommon/VertexShaderManager.h index 9678aae58f..600ba3b10f 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.h +++ b/Source/Core/VideoCommon/VertexShaderManager.h @@ -4,10 +4,9 @@ #pragma once #include +#include #include -#include -#include "Common/BitSet.h" #include "Common/CommonTypes.h" #include "Common/Matrix.h" #include "VideoCommon/ConstantManager.h" @@ -26,7 +25,7 @@ public: // constant management void SetProjectionMatrix(XFStateManager& xf_state_manager); - void SetConstants(const std::vector& textures, XFStateManager& xf_state_manager); + void SetConstants(std::span textures, XFStateManager& xf_state_manager); // data: 3 floats representing the X, Y and Z vertex model coordinates and the posmatrix index. // out: 4 floats which will be initialized with the corresponding clip space coordinates diff --git a/Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp b/Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp index 44e4cde30e..5335452588 100644 --- a/Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp +++ b/Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp @@ -13,7 +13,7 @@ #include -static bool RoundTrippableDisassemble(const std::vector& code, std::string& text) +static bool RoundTrippableDisassemble(std::span code, std::string& text) { DSP::AssemblerSettings settings; settings.ext_separator = '\''; @@ -29,7 +29,7 @@ static bool RoundTrippableDisassemble(const std::vector& code, std::string& // This test goes from text ASM to binary to text ASM and once again back to binary. // Then the two binaries are compared. -static bool RoundTrip(const std::vector& code1) +static bool RoundTrip(std::span code1) { std::vector code2; std::string text; @@ -90,7 +90,7 @@ static bool SuperTrip(const char* asm_code) } // Assembles asm_code, and verifies that it matches code1. -static bool AssembleAndCompare(const char* asm_code, const std::vector& code1) +static bool AssembleAndCompare(const char* asm_code, std::span code1) { std::vector code2; if (!DSP::Assemble(asm_code, code2))