Merge pull request #14500 from Sintendo/span2

Replace `const std::vector&` arguments with `std::span`
This commit is contained in:
Jordan Woyak
2026-04-11 14:55:41 -05:00
committed by GitHub
79 changed files with 164 additions and 146 deletions
+1 -1
View File
@@ -486,7 +486,7 @@ void Lexer::EatAndReset()
SetIdentifierMatchRule(IdentifierMatchRule::Typical); SetIdentifierMatchRule(IdentifierMatchRule::Typical);
} }
std::optional<std::string_view> Lexer::RunDfa(const std::vector<DfaNode>& dfa) const std::optional<std::string_view> Lexer::RunDfa(std::span<const DfaNode> dfa) const
{ {
size_t dfa_index = 0; size_t dfa_index = 0;
bool transition_found; bool transition_found;
+2 -1
View File
@@ -7,6 +7,7 @@
#include <array> #include <array>
#include <deque> #include <deque>
#include <optional> #include <optional>
#include <span>
#include <string_view> #include <string_view>
#include <vector> #include <vector>
@@ -166,7 +167,7 @@ public:
} }
private: private:
std::optional<std::string_view> RunDfa(const std::vector<DfaNode>& dfa) const; std::optional<std::string_view> RunDfa(std::span<const DfaNode> dfa) const;
void SkipWs() const; void SkipWs() const;
void FeedbackTokens() const; void FeedbackTokens() const;
bool IdentifierHeadExtra(char h) const; bool IdentifierHeadExtra(char h) const;
+1 -1
View File
@@ -89,7 +89,7 @@ void Watches::RemoveWatch(std::size_t index)
m_watches.erase(m_watches.begin() + index); m_watches.erase(m_watches.begin() + index);
} }
void Watches::LoadFromStrings(const std::vector<std::string>& watches) void Watches::LoadFromStrings(std::span<const std::string> watches)
{ {
for (const std::string& watch : watches) for (const std::string& watch : watches)
{ {
+2 -1
View File
@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <cstddef> #include <cstddef>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -42,7 +43,7 @@ public:
void DisableWatch(std::size_t index); void DisableWatch(std::size_t index);
bool HasEnabledWatch(u32 address) const; bool HasEnabledWatch(u32 address) const;
void RemoveWatch(std::size_t index); void RemoveWatch(std::size_t index);
void LoadFromStrings(const std::vector<std::string>& watches); void LoadFromStrings(std::span<const std::string> watches);
std::vector<std::string> SaveToStrings() const; std::vector<std::string> SaveToStrings() const;
void Clear(); void Clear();
+2 -2
View File
@@ -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); return m_impl->Fetch(url, Impl::Method::GET, headers, nullptr, 0, codes);
} }
HttpRequest::Response HttpRequest::Post(const std::string& url, const std::vector<u8>& payload, HttpRequest::Response HttpRequest::Post(const std::string& url, std::span<const u8> payload,
const Headers& headers, AllowedReturnCodes codes) const Headers& headers, AllowedReturnCodes codes)
{ {
return m_impl->Fetch(url, Impl::Method::POST, headers, payload.data(), payload.size(), 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) const Headers& headers, AllowedReturnCodes codes)
{ {
return m_impl->Fetch(url, Impl::Method::POST, headers, return m_impl->Fetch(url, Impl::Method::POST, headers,
+3 -2
View File
@@ -10,6 +10,7 @@
#include <optional> #include <optional>
#include <span> #include <span>
#include <string> #include <string>
#include <string_view>
#include <vector> #include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
@@ -50,9 +51,9 @@ public:
std::string GetHeaderValue(std::string_view name) const; std::string GetHeaderValue(std::string_view name) const;
Response Get(const std::string& url, const Headers& headers = {}, Response Get(const std::string& url, const Headers& headers = {},
AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only); AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
Response Post(const std::string& url, const std::vector<u8>& payload, const Headers& headers = {}, Response Post(const std::string& url, std::span<const u8> payload, const Headers& headers = {},
AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only); 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); AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
Response PostMultiform(const std::string& url, std::span<Multiform> multiform, Response PostMultiform(const std::string& url, std::span<Multiform> multiform,
+3 -3
View File
@@ -462,7 +462,7 @@ DHCPBody::DHCPBody(u32 transaction, const MACAddress& client_address, u32 new_ip
DHCPPacket::DHCPPacket() = default; DHCPPacket::DHCPPacket() = default;
DHCPPacket::DHCPPacket(const std::vector<u8>& data) DHCPPacket::DHCPPacket(std::span<const u8> data)
{ {
if (data.size() < DHCPBody::SIZE) if (data.size() < DHCPBody::SIZE)
return; return;
@@ -489,7 +489,7 @@ DHCPPacket::DHCPPacket(const std::vector<u8>& data)
} }
} }
void DHCPPacket::AddOption(u8 fnc, const std::vector<u8>& params) void DHCPPacket::AddOption(u8 fnc, std::span<const u8> params)
{ {
if (params.size() > 255) if (params.size() > 255)
return; return;
@@ -507,7 +507,7 @@ std::vector<u8> DHCPPacket::Build() const
{ {
result.insert(result.end(), opt.begin(), opt.end()); result.insert(result.end(), opt.begin(), opt.end());
} }
const std::vector<u8> no_option = {255, 0, 0, 0}; constexpr auto no_option = std::to_array<u8>({255, 0, 0, 0});
result.insert(result.end(), no_option.begin(), no_option.end()); result.insert(result.end(), no_option.begin(), no_option.end());
return result; return result;
+8 -2
View File
@@ -4,7 +4,9 @@
#pragma once #pragma once
#include <array> #include <array>
#include <initializer_list>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <type_traits> #include <type_traits>
@@ -183,8 +185,12 @@ static_assert(sizeof(DHCPBody) == DHCPBody::SIZE);
struct DHCPPacket struct DHCPPacket
{ {
DHCPPacket(); DHCPPacket();
DHCPPacket(const std::vector<u8>& data); DHCPPacket(std::span<const u8> data);
void AddOption(u8 fnc, const std::vector<u8>& params); void AddOption(u8 fnc, std::span<const u8> params);
void AddOption(u8 fnc, std::initializer_list<u8> params)
{
AddOption(fnc, {params.begin(), params.end()});
}
std::vector<u8> Build() const; std::vector<u8> Build() const;
DHCPBody body; DHCPBody body;
+1 -1
View File
@@ -31,7 +31,7 @@ DolReader::DolReader(const std::string& filename) : BootExecutableReader(filenam
DolReader::~DolReader() = default; DolReader::~DolReader() = default;
bool DolReader::Initialize(const std::vector<u8>& buffer) bool DolReader::Initialize(std::span<const u8> buffer)
{ {
if (buffer.size() < sizeof(SDolHeader) || buffer.size() > UINT32_MAX) if (buffer.size() < sizeof(SDolHeader) || buffer.size() > UINT32_MAX)
return false; return false;
+1 -1
View File
@@ -65,7 +65,7 @@ private:
bool m_is_ancast; bool m_is_ancast;
// Copy sections to internal buffers // Copy sections to internal buffers
bool Initialize(const std::vector<u8>& buffer); bool Initialize(std::span<const u8> buffer);
bool LoadAncastIntoMemory(Core::System& system) const; bool LoadAncastIntoMemory(Core::System& system) const;
}; };
+2 -2
View File
@@ -111,7 +111,7 @@ TryReadValueFromEmulatedMemory(const Core::CPUThreadGuard& guard, u32 addr,
template <typename T> template <typename T>
auto Cheats::NewSearch(const Core::CPUThreadGuard& guard, auto Cheats::NewSearch(const Core::CPUThreadGuard& guard,
const std::vector<Cheats::MemoryRange>& memory_ranges, std::span<const Cheats::MemoryRange> memory_ranges,
PowerPC::RequestedAddressSpace address_space, bool aligned, PowerPC::RequestedAddressSpace address_space, bool aligned,
const std::function<bool(const T& value)>& validator) const std::function<bool(const T& value)>& validator)
-> std::expected<std::vector<SearchResult<T>>, SearchErrorCode> -> std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
@@ -164,7 +164,7 @@ auto Cheats::NewSearch(const Core::CPUThreadGuard& guard,
template <typename T> template <typename T>
auto Cheats::NextSearch( auto Cheats::NextSearch(
const Core::CPUThreadGuard& guard, const std::vector<Cheats::SearchResult<T>>& previous_results, const Core::CPUThreadGuard& guard, std::span<const Cheats::SearchResult<T>> previous_results,
PowerPC::RequestedAddressSpace address_space, PowerPC::RequestedAddressSpace address_space,
const std::function<bool(const T& new_value, const T& old_value)>& validator) const std::function<bool(const T& new_value, const T& old_value)>& validator)
-> std::expected<std::vector<SearchResult<T>>, SearchErrorCode> -> std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
+2 -2
View File
@@ -117,7 +117,7 @@ std::vector<u8> GetValueAsByteVector(const SearchValue& value);
// for which the given validator returns true. // for which the given validator returns true.
template <typename T> template <typename T>
std::expected<std::vector<SearchResult<T>>, SearchErrorCode> std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
NewSearch(const Core::CPUThreadGuard& guard, const std::vector<MemoryRange>& memory_ranges, NewSearch(const Core::CPUThreadGuard& guard, std::span<const MemoryRange> memory_ranges,
PowerPC::RequestedAddressSpace address_space, bool aligned, PowerPC::RequestedAddressSpace address_space, bool aligned,
const std::function<bool(const T& value)>& validator); const std::function<bool(const T& value)>& validator);
@@ -125,7 +125,7 @@ NewSearch(const Core::CPUThreadGuard& guard, const std::vector<MemoryRange>& mem
// which the given validator returns true. // which the given validator returns true.
template <typename T> template <typename T>
std::expected<std::vector<SearchResult<T>>, SearchErrorCode> std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
NextSearch(const Core::CPUThreadGuard& guard, const std::vector<SearchResult<T>>& previous_results, NextSearch(const Core::CPUThreadGuard& guard, std::span<const SearchResult<T>> previous_results,
PowerPC::RequestedAddressSpace address_space, PowerPC::RequestedAddressSpace address_space,
const std::function<bool(const T& new_value, const T& old_value)>& validator); const std::function<bool(const T& new_value, const T& old_value)>& validator);
+1 -1
View File
@@ -367,7 +367,7 @@ std::vector<std::string> GetIsoPaths()
return paths; return paths;
} }
void SetIsoPaths(const std::vector<std::string>& paths) void SetIsoPaths(std::span<const std::string> paths)
{ {
size_t old_size = MathUtil::SaturatingCast<size_t>(Config::Get(Config::MAIN_ISO_PATH_COUNT)); size_t old_size = MathUtil::SaturatingCast<size_t>(Config::Get(Config::MAIN_ISO_PATH_COUNT));
size_t new_size = paths.size(); size_t new_size = paths.size();
+1 -1
View File
@@ -218,7 +218,7 @@ extern const Info<int> MAIN_GDB_PORT;
extern const Info<int> MAIN_ISO_PATH_COUNT; extern const Info<int> MAIN_ISO_PATH_COUNT;
extern const Info<std::string> MAIN_SKYLANDERS_PATH; extern const Info<std::string> MAIN_SKYLANDERS_PATH;
std::vector<std::string> GetIsoPaths(); std::vector<std::string> GetIsoPaths();
void SetIsoPaths(const std::vector<std::string>& paths); void SetIsoPaths(std::span<const std::string> paths);
// Main.GBA // Main.GBA
+6 -5
View File
@@ -4,6 +4,7 @@
#include "Core/DSP/DSPCodeUtil.h" #include "Core/DSP/DSPCodeUtil.h"
#include <algorithm> #include <algorithm>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -35,7 +36,7 @@ bool Assemble(const std::string& text, std::vector<u16>& code, bool force)
return assembler.Assemble(text, code); return assembler.Assemble(text, code);
} }
bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& text) bool Disassemble(std::span<const u16> code, bool line_numbers, std::string& text)
{ {
if (code.empty()) if (code.empty())
return false; return false;
@@ -56,7 +57,7 @@ bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& t
// NOTE: This code is called from DSPTool and UnitTests, which do not use the logging system. // 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. // Thus, fmt::print is used instead of the log system.
bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2) bool Compare(std::span<const u16> code1, std::span<const u16> code2)
{ {
if (code1.size() != code2.size()) if (code1.size() != code2.size())
fmt::print("Size difference! 1={} 2={}\n", code1.size(), code2.size()); fmt::print("Size difference! 1={} 2={}\n", code1.size(), code2.size());
@@ -106,7 +107,7 @@ bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
if (code2.size() != code1.size()) if (code2.size() != code1.size())
{ {
fmt::print("Extra code words:\n"); fmt::print("Extra code words:\n");
const std::vector<u16>& 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++) for (u16 i = min_size; i < longest.size(); i++)
{ {
u16 pc = i; u16 pc = i;
@@ -119,7 +120,7 @@ bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
return code1.size() == code2.size() && code1.size() == count_equal; return code1.size() == code2.size() && code1.size() == count_equal;
} }
std::string CodeToBinaryStringBE(const std::vector<u16>& code) std::string CodeToBinaryStringBE(std::span<const u16> code)
{ {
std::string str(code.size() * 2, '\0'); std::string str(code.size() * 2, '\0');
@@ -153,7 +154,7 @@ std::optional<std::vector<u16>> LoadBinary(const std::string& filename)
return std::make_optional(BinaryStringBEToCode(buffer)); return std::make_optional(BinaryStringBEToCode(buffer));
} }
bool SaveBinary(const std::vector<u16>& code, const std::string& filename) bool SaveBinary(std::span<const u16> code, const std::string& filename)
{ {
const std::string buffer = CodeToBinaryStringBE(code); const std::string buffer = CodeToBinaryStringBE(code);
+5 -4
View File
@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -12,16 +13,16 @@
namespace DSP namespace DSP
{ {
bool Assemble(const std::string& text, std::vector<u16>& code, bool force = false); bool Assemble(const std::string& text, std::vector<u16>& code, bool force = false);
bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& text); bool Disassemble(std::span<const u16> code, bool line_numbers, std::string& text);
bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2); bool Compare(std::span<const u16> code1, std::span<const u16> code2);
// Big-endian, for writing straight to file using File::WriteStringToFile. // Big-endian, for writing straight to file using File::WriteStringToFile.
std::string CodeToBinaryStringBE(const std::vector<u16>& code); std::string CodeToBinaryStringBE(std::span<const u16> code);
std::vector<u16> BinaryStringBEToCode(const std::string& str); std::vector<u16> BinaryStringBEToCode(const std::string& str);
// Load code (big endian binary). // Load code (big endian binary).
std::optional<std::vector<u16>> LoadBinary(const std::string& filename); std::optional<std::vector<u16>> LoadBinary(const std::string& filename);
bool SaveBinary(const std::vector<u16>& code, const std::string& filename); bool SaveBinary(std::span<const u16> code, const std::string& filename);
bool DumpDSPCode(const u8* code_be, size_t size_in_bytes, u32 crc); bool DumpDSPCode(const u8* code_be, size_t size_in_bytes, u32 crc);
} // namespace DSP } // namespace DSP
+2 -3
View File
@@ -7,7 +7,6 @@
#include <limits> #include <limits>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector>
#include <fmt/format.h> #include <fmt/format.h>
@@ -23,7 +22,7 @@ DSPDisassembler::DSPDisassembler(const AssemblerSettings& settings) : settings_(
{ {
} }
bool DSPDisassembler::Disassemble(const std::vector<u16>& code, std::string& text) bool DSPDisassembler::Disassemble(std::span<const u16> code, std::string& text)
{ {
if (code.size() > std::numeric_limits<u16>::max()) if (code.size() > std::numeric_limits<u16>::max())
{ {
@@ -140,7 +139,7 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1
return buf; return buf;
} }
bool DSPDisassembler::DisassembleOpcode(const std::vector<u16>& code, u16* pc, std::string& dest) bool DSPDisassembler::DisassembleOpcode(std::span<const u16> code, u16* pc, std::string& dest)
{ {
return DisassembleOpcode(code.data(), code.size(), pc, dest); return DisassembleOpcode(code.data(), code.size(), pc, dest);
} }
+3 -3
View File
@@ -4,8 +4,8 @@
#pragma once #pragma once
#include <span>
#include <string> #include <string>
#include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
@@ -32,11 +32,11 @@ class DSPDisassembler
public: public:
explicit DSPDisassembler(const AssemblerSettings& settings); explicit DSPDisassembler(const AssemblerSettings& settings);
bool Disassemble(const std::vector<u16>& code, std::string& text); bool Disassemble(std::span<const u16> code, std::string& text);
// Disassembles the given opcode at pc and increases pc by the opcode's size. // 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. // The PC is wrapped such that 0x0000 and 0x8000 both point to the start of the buffer.
bool DisassembleOpcode(const std::vector<u16>& code, u16* pc, std::string& dest); bool DisassembleOpcode(std::span<const u16> code, u16* pc, std::string& dest);
bool DisassembleOpcode(const u16* binbuf, size_t binbuf_size, u16* pc, std::string& dest); bool DisassembleOpcode(const u16* binbuf, size_t binbuf_size, u16* pc, std::string& dest);
private: private:
+2 -1
View File
@@ -5,6 +5,7 @@
#include <cstddef> #include <cstddef>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -40,7 +41,7 @@ public:
virtual void DisableWatch(std::size_t index) = 0; virtual void DisableWatch(std::size_t index) = 0;
virtual bool HasEnabledWatch(u32 address) const = 0; virtual bool HasEnabledWatch(u32 address) const = 0;
virtual void RemoveWatch(std::size_t index) = 0; virtual void RemoveWatch(std::size_t index) = 0;
virtual void LoadWatchesFromStrings(const std::vector<std::string>& watches) = 0; virtual void LoadWatchesFromStrings(std::span<const std::string> watches) = 0;
virtual std::vector<std::string> SaveWatchesToStrings() const = 0; virtual std::vector<std::string> SaveWatchesToStrings() const = 0;
virtual void ClearWatches() = 0; virtual void ClearWatches() = 0;
@@ -158,7 +158,7 @@ void PPCDebugInterface::RemoveWatch(std::size_t index)
return m_watches.RemoveWatch(index); return m_watches.RemoveWatch(index);
} }
void PPCDebugInterface::LoadWatchesFromStrings(const std::vector<std::string>& watches) void PPCDebugInterface::LoadWatchesFromStrings(std::span<const std::string> watches)
{ {
m_watches.LoadFromStrings(watches); m_watches.LoadFromStrings(watches);
} }
@@ -65,7 +65,7 @@ public:
void DisableWatch(std::size_t index) override; void DisableWatch(std::size_t index) override;
bool HasEnabledWatch(u32 address) const override; bool HasEnabledWatch(u32 address) const override;
void RemoveWatch(std::size_t index) override; void RemoveWatch(std::size_t index) override;
void LoadWatchesFromStrings(const std::vector<std::string>& watches) override; void LoadWatchesFromStrings(std::span<const std::string> watches) override;
std::vector<std::string> SaveWatchesToStrings() const override; std::vector<std::string> SaveWatchesToStrings() const override;
void ClearWatches() override; void ClearWatches() override;
+1 -2
View File
@@ -389,8 +389,7 @@ bool FifoDataFile::GetFlag(u32 flag) const
return !!(m_Flags & flag); return !!(m_Flags & flag);
} }
u64 FifoDataFile::WriteMemoryUpdates(const std::vector<MemoryUpdate>& memUpdates, u64 FifoDataFile::WriteMemoryUpdates(std::span<const MemoryUpdate> memUpdates, File::IOFile& file)
File::IOFile& file)
{ {
// Add space for memory update list // Add space for memory update list
u64 updateListOffset = file.Tell(); u64 updateListOffset = file.Tell();
+2 -1
View File
@@ -5,6 +5,7 @@
#include <array> #include <array>
#include <memory> #include <memory>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -92,7 +93,7 @@ private:
void SetFlag(u32 flag, bool set); void SetFlag(u32 flag, bool set);
bool GetFlag(u32 flag) const; bool GetFlag(u32 flag) const;
u64 WriteMemoryUpdates(const std::vector<MemoryUpdate>& memUpdates, File::IOFile& file); u64 WriteMemoryUpdates(std::span<const MemoryUpdate> memUpdates, File::IOFile& file);
static void ReadMemoryUpdates(u64 fileOffset, u32 numUpdates, static void ReadMemoryUpdates(u64 fileOffset, u32 numUpdates,
std::vector<MemoryUpdate>& memUpdates, File::IOFile& file); std::vector<MemoryUpdate>& memUpdates, File::IOFile& file);
+1 -1
View File
@@ -231,7 +231,7 @@ static void SaveGeckoCode(std::vector<std::string>& lines, const GeckoCode& gcod
lines.push_back('*' + note); lines.push_back('*' + note);
} }
void SaveCodes(Common::IniFile& inifile, const std::vector<GeckoCode>& gcodes) void SaveCodes(Common::IniFile& inifile, std::span<const GeckoCode> gcodes)
{ {
std::vector<std::string> lines; std::vector<std::string> lines;
std::vector<std::string> enabled_lines; std::vector<std::string> enabled_lines;
+2 -1
View File
@@ -5,6 +5,7 @@
#include <expected> #include <expected>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -19,7 +20,7 @@ namespace Gecko
{ {
std::vector<GeckoCode> LoadCodes(const Common::IniFile& globalIni, const Common::IniFile& localIni); std::vector<GeckoCode> LoadCodes(const Common::IniFile& globalIni, const Common::IniFile& localIni);
std::expected<std::vector<GeckoCode>, int> DownloadCodes(std::string gametdb_id); std::expected<std::vector<GeckoCode>, int> DownloadCodes(std::string gametdb_id);
void SaveCodes(Common::IniFile& inifile, const std::vector<GeckoCode>& gcodes); void SaveCodes(Common::IniFile& inifile, std::span<const GeckoCode> gcodes);
std::optional<GeckoCode::Code> DeserializeLine(const std::string& line); std::optional<GeckoCode::Code> DeserializeLine(const std::string& line);
} // namespace Gecko } // namespace Gecko
+3 -3
View File
@@ -133,7 +133,7 @@ void DVDInterface::DoState(PointerWrap& p)
} }
size_t DVDInterface::ProcessDTKSamples(s16* target_samples, size_t target_block_count, size_t DVDInterface::ProcessDTKSamples(s16* target_samples, size_t target_block_count,
const std::vector<u8>& audio_data) std::span<const u8> audio_data)
{ {
const size_t block_count_to_process = const size_t block_count_to_process =
std::min(target_block_count, audio_data.size() / StreamADPCM::ONE_BLOCK_SIZE); 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, void DVDInterface::DTKStreamingCallback(DIInterruptType interrupt_type,
const std::vector<u8>& audio_data, s64 cycles_late) std::span<const u8> audio_data, s64 cycles_late)
{ {
auto& ai = m_system.GetAudioInterface(); auto& ai = m_system.GetAudioInterface();
@@ -1304,7 +1304,7 @@ void DVDInterface::SetDriveError(DriveError error)
} }
void DVDInterface::FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, void DVDInterface::FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type,
s64 cycles_late, const std::vector<u8>& data) s64 cycles_late, std::span<const u8> data)
{ {
// The data parameter contains the requested data iff this was called from DVDThread, and is // 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. // empty otherwise. DVDThread is the only source of ReplyType::NoReply and ReplyType::DTK.
+4 -3
View File
@@ -6,6 +6,7 @@
#include <array> #include <array>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -170,17 +171,17 @@ public:
// Used by DVDThread // Used by DVDThread
void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, s64 cycles_late, void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, s64 cycles_late,
const std::vector<u8>& data = std::vector<u8>()); std::span<const u8> data = {});
// Used by IOS HLE // Used by IOS HLE
void SetInterruptEnabled(DIInterruptType interrupt, bool enabled); void SetInterruptEnabled(DIInterruptType interrupt, bool enabled);
void ClearInterrupt(DIInterruptType interrupt); void ClearInterrupt(DIInterruptType interrupt);
private: private:
void DTKStreamingCallback(DIInterruptType interrupt_type, const std::vector<u8>& audio_data, void DTKStreamingCallback(DIInterruptType interrupt_type, std::span<const u8> audio_data,
s64 cycles_late); s64 cycles_late);
size_t ProcessDTKSamples(s16* target_samples, size_t target_block_count, size_t ProcessDTKSamples(s16* target_samples, size_t target_block_count,
const std::vector<u8>& audio_data); const std::span<const u8> audio_data);
u32 AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process); u32 AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process);
void SetLidOpen(); void SetLidOpen();
+5 -6
View File
@@ -124,9 +124,9 @@ bool CEXIETHERNET::BuiltInBBAInterface::IsActivated()
return m_active; return m_active;
} }
void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(const std::vector<u8>& data) void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(std::vector<u8> 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; const u8 next_write_index = (m_queue_write + 1) & 15;
if (next_write_index != m_queue_read) if (next_write_index != m_queue_read)
m_queue_write = next_write_index; m_queue_write = next_write_index;
@@ -178,7 +178,7 @@ void CEXIETHERNET::BuiltInBBAInterface::PollData(std::size_t* datasize)
// Otherwise, enqueue it // Otherwise, enqueue it
const auto socket_data = TryGetDataFromSocket(&net_ref); const auto socket_data = TryGetDataFromSocket(&net_ref);
if (socket_data.has_value()) if (socket_data.has_value())
WriteToQueue(*socket_data); WriteToQueue(std::move(*socket_data));
} }
else else
{ {
@@ -220,7 +220,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleDHCP(const Common::UDPPacket& pack
const u8* router_ip_ptr = reinterpret_cast<const u8*>(&m_router_ip); const u8* router_ip_ptr = reinterpret_cast<const u8*>(&m_router_ip);
const std::vector<u8> ip_part(router_ip_ptr, router_ip_ptr + sizeof(m_router_ip)); const std::vector<u8> ip_part(router_ip_ptr, router_ip_ptr + sizeof(m_router_ip));
const std::vector<u8> timeout_24h = {0, 1, 0x51, 0x80}; constexpr auto timeout_24h = std::to_array<u8>({0, 1, 0x51, 0x80});
Common::DHCPPacket reply; Common::DHCPPacket reply;
reply.body = Common::DHCPBody(request.transaction_id, m_current_mac, m_current_ip, m_router_ip); 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: case IPPROTO_IGMP:
{ {
// Acknowledge IGMP packet // Acknowledge IGMP packet
const std::vector<u8> data(frame, frame + size); WriteToQueue({frame, frame + size});
WriteToQueue(data);
break; break;
} }
+1 -1
View File
@@ -463,7 +463,7 @@ private:
Common::Flag m_read_thread_shutdown; Common::Flag m_read_thread_shutdown;
static void ReadThreadHandler(BuiltInBBAInterface* self); static void ReadThreadHandler(BuiltInBBAInterface* self);
#endif #endif
void WriteToQueue(const std::vector<u8>& data); void WriteToQueue(std::vector<u8> data);
bool WillQueueOverrun() const; bool WillQueueOverrun() const;
void PollData(std::size_t* datasize); void PollData(std::size_t* datasize);
std::optional<std::vector<u8>> TryGetDataFromSocket(StackRef* ref); std::optional<std::vector<u8>> TryGetDataFromSocket(StackRef* ref);
+1 -1
View File
@@ -369,7 +369,7 @@ bool MemoryManager::TryAddLargePageTableMapping(u32 logical_address, u32 transla
return CanCreateHostMappingForGuestPages(entries); return CanCreateHostMappingForGuestPages(entries);
} }
bool MemoryManager::CanCreateHostMappingForGuestPages(const std::vector<u32>& entries) const bool MemoryManager::CanCreateHostMappingForGuestPages(std::span<const u32> entries) const
{ {
const u32 translated_address = entries[0]; const u32 translated_address = entries[0];
if ((translated_address & (m_page_size - 1)) != 0) if ((translated_address & (m_page_size - 1)) != 0)
+1 -1
View File
@@ -289,7 +289,7 @@ private:
void TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool writeable); void TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool writeable);
bool TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool TryAddLargePageTableMapping(u32 logical_address, u32 translated_address,
std::map<u32, std::vector<u32>>& map); std::map<u32, std::vector<u32>>& map);
bool CanCreateHostMappingForGuestPages(const std::vector<u32>& entries) const; bool CanCreateHostMappingForGuestPages(std::span<const u32> entries) const;
void AddHostPageTableMapping(u32 logical_address, u32 translated_address, bool writeable, void AddHostPageTableMapping(u32 logical_address, u32 translated_address, bool writeable,
u32 logical_size); u32 logical_size);
void RemoveLargePageTableMapping(u32 logical_address); void RemoveLargePageTableMapping(u32 logical_address);
+2 -2
View File
@@ -158,7 +158,7 @@ public:
bool WriteBkHeader(const BkHeader& bk_header) override { return true; } bool WriteBkHeader(const BkHeader& bk_header) override { return true; }
bool WriteFiles(const std::vector<SaveFile>& files) override bool WriteFiles(std::span<const SaveFile> files) override
{ {
if (!m_uid || !m_gid) if (!m_uid || !m_gid)
return false; return false;
@@ -390,7 +390,7 @@ public:
return m_file.Seek(sizeof(Header), File::SeekOrigin::Begin) && m_file.WriteArray(&bk_header, 1); return m_file.Seek(sizeof(Header), File::SeekOrigin::Begin) && m_file.WriteArray(&bk_header, 1);
} }
bool WriteFiles(const std::vector<SaveFile>& files) override bool WriteFiles(std::span<const SaveFile> files) override
{ {
if (!m_file.Seek(sizeof(Header) + sizeof(BkHeader), File::SeekOrigin::Begin)) if (!m_file.Seek(sizeof(Header) + sizeof(BkHeader), File::SeekOrigin::Begin))
return false; return false;
+2 -1
View File
@@ -10,6 +10,7 @@
#include <array> #include <array>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -108,6 +109,6 @@ public:
virtual std::optional<std::vector<SaveFile>> ReadFiles() = 0; virtual std::optional<std::vector<SaveFile>> ReadFiles() = 0;
virtual bool WriteHeader(const Header& header) = 0; virtual bool WriteHeader(const Header& header) = 0;
virtual bool WriteBkHeader(const BkHeader& bk_header) = 0; virtual bool WriteBkHeader(const BkHeader& bk_header) = 0;
virtual bool WriteFiles(const std::vector<SaveFile>& files) = 0; virtual bool WriteFiles(std::span<const SaveFile> files) = 0;
}; };
} // namespace WiiSave } // namespace WiiSave
+2 -1
View File
@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -36,7 +37,7 @@ class GBAHostInterface
public: public:
virtual ~GBAHostInterface() = default; virtual ~GBAHostInterface() = default;
virtual void GameChanged() = 0; virtual void GameChanged() = 0;
virtual void FrameEnded(const std::vector<u32>& video_buffer) = 0; virtual void FrameEnded(std::span<const u32> video_buffer) = 0;
}; };
enum class HostMessageID enum class HostMessageID
+4 -4
View File
@@ -4,7 +4,7 @@
#pragma once #pragma once
#include <array> #include <array>
#include <map> #include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -376,8 +376,8 @@ private:
IPCReply SeekContent(u32 uid, const IOCtlVRequest& request); IPCReply SeekContent(u32 uid, const IOCtlVRequest& request);
// Title information // Title information
IPCReply GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request); IPCReply GetTitleCount(std::span<const u64> titles, const IOCtlVRequest& request);
IPCReply GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request); IPCReply GetTitles(std::span<const u64> titles, const IOCtlVRequest& request);
IPCReply GetOwnedTitleCount(const IOCtlVRequest& request); IPCReply GetOwnedTitleCount(const IOCtlVRequest& request);
IPCReply GetOwnedTitles(const IOCtlVRequest& request); IPCReply GetOwnedTitles(const IOCtlVRequest& request);
IPCReply GetTitleCount(const IOCtlVRequest& request); IPCReply GetTitleCount(const IOCtlVRequest& request);
@@ -416,7 +416,7 @@ private:
void FinishInit(); void FinishInit();
s32 WriteSystemFile(const std::string& path, const std::vector<u8>& data, Ticks ticks = {}); s32 WriteSystemFile(const std::string& path, std::span<const u8> data, Ticks ticks = {});
s32 WriteLaunchFile(const ES::TMDReader& tmd, Ticks ticks = {}); s32 WriteLaunchFile(const ES::TMDReader& tmd, Ticks ticks = {});
bool BootstrapPPC(); bool BootstrapPPC();
+1 -1
View File
@@ -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); return fmt::format("{}/{:08x}.app", Common::GetTitleContentPath(title_id), content.id);
} }
s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector<u8>& data, Ticks ticks) s32 ESDevice::WriteSystemFile(const std::string& path, std::span<const u8> data, Ticks ticks)
{ {
auto& fs = GetEmulationKernel().GetFSCore(); auto& fs = GetEmulationKernel().GetFSCore();
const std::string tmp_path = "/tmp/" + PathToFileName(path); const std::string tmp_path = "/tmp/" + PathToFileName(path);
+2 -2
View File
@@ -120,7 +120,7 @@ IPCReply ESDevice::GetTMDStoredContents(const IOCtlVRequest& request)
return GetStoredContents(tmd, request); return GetStoredContents(tmd, request);
} }
IPCReply ESDevice::GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request) IPCReply ESDevice::GetTitleCount(std::span<const u64> titles, const IOCtlVRequest& request)
{ {
if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 4) if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 4)
return IPCReply(ES_EINVAL); return IPCReply(ES_EINVAL);
@@ -132,7 +132,7 @@ IPCReply ESDevice::GetTitleCount(const std::vector<u64>& titles, const IOCtlVReq
return IPCReply(IPC_SUCCESS); return IPCReply(IPC_SUCCESS);
} }
IPCReply ESDevice::GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request) IPCReply ESDevice::GetTitles(std::span<const u64> titles, const IOCtlVRequest& request)
{ {
if (!request.HasNumberOfValidVectors(1, 1)) if (!request.HasNumberOfValidVectors(1, 1))
return IPCReply(ES_EINVAL); return IPCReply(ES_EINVAL);
+1 -1
View File
@@ -372,7 +372,7 @@ IPCReply ESDevice::ImportContentData(Context& context, const IOCtlVRequest& requ
return IPCReply(m_core.ImportContentData(context, content_fd, data_start, data_size)); return IPCReply(m_core.ImportContentData(context, content_fd, data_start, data_size));
} }
static bool CheckIfContentHashMatches(const std::vector<u8>& content, const ES::Content& info) static bool CheckIfContentHashMatches(std::span<const u8> content, const ES::Content& info)
{ {
return Common::SHA1::CalculateDigest(content.data(), info.size) == info.sha1; return Common::SHA1::CalculateDigest(content.data(), info.size) == info.sha1;
} }
+2 -2
View File
@@ -43,7 +43,7 @@ void ARCUnpacker::Reset()
m_whole_file.clear(); m_whole_file.clear();
} }
void ARCUnpacker::AddBytes(const std::vector<u8>& bytes) void ARCUnpacker::AddBytes(std::span<const u8> bytes)
{ {
m_whole_file.insert(m_whole_file.end(), bytes.begin(), bytes.end()); m_whole_file.insert(m_whole_file.end(), bytes.begin(), bytes.end());
} }
@@ -244,7 +244,7 @@ std::optional<IPCReply> WFSIDevice::IOCtl(const IOCtlRequest& request)
"IOCTL_WFSI_IMPORT_CONTENT_END"; "IOCTL_WFSI_IMPORT_CONTENT_END";
INFO_LOG_FMT(IOS_WFS, "{}", ioctl_name); INFO_LOG_FMT(IOS_WFS, "{}", ioctl_name);
const auto callback = [this](const std::string& filename, const std::vector<u8>& bytes) { const auto callback = [this](const std::string& filename, std::span<const u8> bytes) {
INFO_LOG_FMT(IOS_WFS, "Extract: {} ({} bytes)", filename, bytes.size()); INFO_LOG_FMT(IOS_WFS, "Extract: {} ({} bytes)", filename, bytes.size());
const std::string path = WFS::NativePath(m_base_extract_path + '/' + filename); const std::string path = WFS::NativePath(m_base_extract_path + '/' + filename);
+3 -2
View File
@@ -5,6 +5,7 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -22,9 +23,9 @@ public:
ARCUnpacker() { Reset(); } ARCUnpacker() { Reset(); }
void Reset(); void Reset();
void AddBytes(const std::vector<u8>& bytes); void AddBytes(std::span<const u8> bytes);
using WriteCallback = std::function<void(const std::string&, const std::vector<u8>&)>; using WriteCallback = std::function<void(const std::string&, std::span<const u8>)>;
void Extract(const WriteCallback& callback); void Extract(const WriteCallback& callback);
private: private:
+1 -2
View File
@@ -13,7 +13,6 @@
#include <string> #include <string>
#include <thread> #include <thread>
#include <unordered_map> #include <unordered_map>
#include <utility>
#include <vector> #include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
@@ -89,7 +88,7 @@ public:
virtual void OnIndexRefreshFailed(std::string error) = 0; virtual void OnIndexRefreshFailed(std::string error) = 0;
virtual void ShowChunkedProgressDialog(const std::string& title, u64 data_size, virtual void ShowChunkedProgressDialog(const std::string& title, u64 data_size,
const std::vector<int>& players) = 0; std::span<const int> players) = 0;
virtual void HideChunkedProgressDialog() = 0; virtual void HideChunkedProgressDialog() = 0;
virtual void SetChunkedProgress(int pid, u64 progress) = 0; virtual void SetChunkedProgress(int pid, u64 progress) = 0;
+1 -1
View File
@@ -116,7 +116,7 @@ bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet
return CompressFolderIntoPacketInternal(File::ScanDirectoryTree(folder_path, true), packet); return CompressFolderIntoPacketInternal(File::ScanDirectoryTree(folder_path, true), packet);
} }
bool CompressBufferIntoPacket(const std::vector<u8>& in_buffer, sf::Packet& packet) bool CompressBufferIntoPacket(std::span<const u8> in_buffer, sf::Packet& packet)
{ {
const u64 size = in_buffer.size(); const u64 size = in_buffer.size();
packet << size; packet << size;
+2 -2
View File
@@ -5,9 +5,9 @@
#include <SFML/Network/Packet.hpp> #include <SFML/Network/Packet.hpp>
#include <array>
#include <chrono> #include <chrono>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -22,7 +22,7 @@ constexpr std::chrono::milliseconds PEER_TIMEOUT = 30s;
bool CompressFileIntoPacket(const std::string& file_path, sf::Packet& packet); bool CompressFileIntoPacket(const std::string& file_path, sf::Packet& packet);
bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet); bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet);
bool CompressBufferIntoPacket(const std::vector<u8>& in_buffer, sf::Packet& packet); bool CompressBufferIntoPacket(std::span<const u8> in_buffer, sf::Packet& packet);
bool DecompressPacketIntoFile(sf::Packet& packet, const std::string& file_path); bool DecompressPacketIntoFile(sf::Packet& packet, const std::string& file_path);
bool DecompressPacketIntoFolder(sf::Packet& packet, const std::string& folder_path); bool DecompressPacketIntoFolder(sf::Packet& packet, const std::string& folder_path);
std::optional<std::vector<u8>> DecompressPacketIntoBuffer(sf::Packet& packet); std::optional<std::vector<u8>> DecompressPacketIntoBuffer(sf::Packet& packet);
+1 -1
View File
@@ -149,7 +149,7 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>* patches,
} }
} }
void SavePatchSection(Common::IniFile* local_ini, const std::vector<Patch>& patches) void SavePatchSection(Common::IniFile* local_ini, std::span<const Patch> patches)
{ {
std::vector<std::string> lines; std::vector<std::string> lines;
std::vector<std::string> lines_enabled; std::vector<std::string> lines_enabled;
+2 -1
View File
@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -53,7 +54,7 @@ std::optional<PatchEntry> DeserializeLine(std::string line);
std::string SerializeLine(const PatchEntry& entry); std::string SerializeLine(const PatchEntry& entry);
void LoadPatchSection(const std::string& section, std::vector<Patch>* patches, void LoadPatchSection(const std::string& section, std::vector<Patch>* patches,
const Common::IniFile& globalIni, const Common::IniFile& localIni); const Common::IniFile& globalIni, const Common::IniFile& localIni);
void SavePatchSection(Common::IniFile* local_ini, const std::vector<Patch>& patches); void SavePatchSection(Common::IniFile* local_ini, std::span<const Patch> patches);
void LoadPatches(); void LoadPatches();
void AddMemoryPatch(std::size_t index); void AddMemoryPatch(std::size_t index);
+1 -1
View File
@@ -267,7 +267,7 @@ struct SlotWithTimestamp
} // namespace } // namespace
// Returns first slot number (1-based indexing) not in the vector. // Returns first slot number (1-based indexing) not in the vector.
static std::optional<int> GetEmptySlot(const std::vector<SlotWithTimestamp>& used_slots) static std::optional<int> GetEmptySlot(std::span<const SlotWithTimestamp> used_slots)
{ {
for (int i = 1; i <= int(NUM_STATES); ++i) for (int i = 1; i <= int(NUM_STATES); ++i)
{ {
+2 -2
View File
@@ -346,7 +346,7 @@ private:
}; };
Response GetSystemTitles(); Response GetSystemTitles();
Response ParseTitlesResponse(const std::vector<u8>& response) const; Response ParseTitlesResponse(std::span<const u8> response) const;
bool ShouldInstallTitle(const TitleInfo& title); bool ShouldInstallTitle(const TitleInfo& title);
UpdateResult InstallTitleFromNUS(const std::string& prefix_url, 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::Response
OnlineSystemUpdater::ParseTitlesResponse(const std::vector<u8>& response) const OnlineSystemUpdater::ParseTitlesResponse(std::span<const u8> response) const
{ {
pugi::xml_document doc; pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_buffer(response.data(), response.size()); pugi::xml_parse_result result = doc.load_buffer(response.data(), response.size());
+5 -5
View File
@@ -575,7 +575,7 @@ u64 DirectoryBlobReader::GetDataSize() const
return m_data_size; return m_data_size;
} }
void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(const std::vector<u8>& partition_header, void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(std::span<const u8> partition_header,
const std::string& game_partition_root) const std::string& game_partition_root)
{ {
std::vector<u8> header_bin(WII_NONPARTITION_DISCHEADER_SIZE); std::vector<u8> header_bin(WII_NONPARTITION_DISCHEADER_SIZE);
@@ -585,7 +585,7 @@ void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(const std::vector<u8
SetNonpartitionDiscHeader(partition_header, std::move(header_bin)); SetNonpartitionDiscHeader(partition_header, std::move(header_bin));
} }
void DirectoryBlobReader::SetNonpartitionDiscHeader(const std::vector<u8>& partition_header, void DirectoryBlobReader::SetNonpartitionDiscHeader(std::span<const u8> partition_header,
std::vector<u8> header_bin) std::vector<u8> header_bin)
{ {
const size_t header_bin_size = header_bin.size(); 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); SetWiiRegionData(wii_region_data, region_bin_path);
} }
void DirectoryBlobReader::SetWiiRegionData(const std::vector<u8>& wii_region_data, void DirectoryBlobReader::SetWiiRegionData(std::span<const u8> wii_region_data,
const std::string& log_path) const std::string& log_path)
{ {
std::vector<u8> region_data(0x10, 0x00); std::vector<u8> region_data(0x10, 0x00);
@@ -961,7 +961,7 @@ DirectoryBlobPartition::DirectoryBlobPartition(
} }
void DirectoryBlobPartition::SetDiscType(std::optional<bool> is_wii, void DirectoryBlobPartition::SetDiscType(std::optional<bool> is_wii,
const std::vector<u8>& disc_header) std::span<const u8> disc_header)
{ {
if (is_wii.has_value()) if (is_wii.has_value())
{ {
@@ -1108,7 +1108,7 @@ static void ConvertUTF8NamesToSHIFTJIS(std::vector<FSTBuilderNode>* fst)
} }
} }
static u32 ComputeNameSize(const std::vector<FSTBuilderNode>& files) static u32 ComputeNameSize(std::span<const FSTBuilderNode> files)
{ {
u32 name_size = 0; u32 name_size = 0;
for (const FSTBuilderNode& entry : files) for (const FSTBuilderNode& entry : files)
+4 -5
View File
@@ -200,7 +200,7 @@ public:
void SetKey(std::array<u8, VolumeWii::AES_KEY_SIZE> key) { m_key = key; } void SetKey(std::array<u8, VolumeWii::AES_KEY_SIZE> key) { m_key = key; }
private: private:
void SetDiscType(std::optional<bool> is_wii, const std::vector<u8>& disc_header); void SetDiscType(std::optional<bool> is_wii, std::span<const u8> disc_header);
void SetBI2FromFile(const std::string& bi2_path); void SetBI2FromFile(const std::string& bi2_path);
void SetBI2(std::vector<u8> bi2); void SetBI2(std::vector<u8> bi2);
@@ -296,12 +296,11 @@ private:
bool EncryptPartitionData(u64 offset, u64 size, u8* buffer, u64 partition_data_offset, bool EncryptPartitionData(u64 offset, u64 size, u8* buffer, u64 partition_data_offset,
u64 partition_data_decrypted_size); u64 partition_data_decrypted_size);
void SetNonpartitionDiscHeaderFromFile(const std::vector<u8>& partition_header, void SetNonpartitionDiscHeaderFromFile(std::span<const u8> partition_header,
const std::string& game_partition_root); const std::string& game_partition_root);
void SetNonpartitionDiscHeader(const std::vector<u8>& partition_header, void SetNonpartitionDiscHeader(std::span<const u8> partition_header, std::vector<u8> header_bin);
std::vector<u8> header_bin);
void SetWiiRegionDataFromFile(const std::string& game_partition_root); void SetWiiRegionDataFromFile(const std::string& game_partition_root);
void SetWiiRegionData(const std::vector<u8>& wii_region_data, const std::string& log_path); void SetWiiRegionData(std::span<const u8> wii_region_data, const std::string& log_path);
void SetPartitions(std::vector<PartitionWithType>&& partitions); void SetPartitions(std::vector<PartitionWithType>&& partitions);
void SetPartitionHeader(DirectoryBlobPartition* partition, u64 partition_address); void SetPartitionHeader(DirectoryBlobPartition* partition, u64 partition_address);
+2 -1
View File
@@ -5,6 +5,7 @@
#include <algorithm> #include <algorithm>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -155,7 +156,7 @@ static u64 GetBiggestReferencedOffset(const Volume& volume, const FileInfo& file
} }
} }
u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector<Partition>& partitions) u64 GetBiggestReferencedOffset(const Volume& volume, std::span<const Partition> partitions)
{ {
const u64 disc_header_size = volume.GetVolumeType() == Platform::GameCubeDisc ? 0x460 : 0x50000; const u64 disc_header_size = volume.GetVolumeType() == Platform::GameCubeDisc ? 0x460 : 0x50000;
u64 biggest_offset = disc_header_size; u64 biggest_offset = disc_header_size;
+2 -2
View File
@@ -4,8 +4,8 @@
#pragma once #pragma once
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "DiscIO/Blob.h" #include "DiscIO/Blob.h"
@@ -84,7 +84,7 @@ std::optional<u64> GetFSTOffset(const Volume& volume, const Partition& partition
std::optional<u64> GetFSTSize(const Volume& volume, const Partition& partition); std::optional<u64> GetFSTSize(const Volume& volume, const Partition& partition);
u64 GetBiggestReferencedOffset(const Volume& volume); u64 GetBiggestReferencedOffset(const Volume& volume);
u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector<Partition>& partitions); u64 GetBiggestReferencedOffset(const Volume& volume, std::span<const Partition> partitions);
bool IsGCZBlockSizeLegacyCompatible(int block_size, u64 file_size); bool IsGCZBlockSizeLegacyCompatible(int block_size, u64 file_size);
bool IsDiscImageBlockSizeValid(int block_size, BlobType format); bool IsDiscImageBlockSizeValid(int block_size, BlobType format);
+2 -2
View File
@@ -105,7 +105,7 @@ std::vector<File::DirectIOFile> NFSFileReader::OpenFiles(const std::string& dire
return files; return files;
} }
u64 NFSFileReader::CalculateExpectedRawSize(const std::vector<NFSLBARange>& lba_ranges) u64 NFSFileReader::CalculateExpectedRawSize(std::span<const NFSLBARange> lba_ranges)
{ {
u64 total_blocks = 0; u64 total_blocks = 0;
for (const NFSLBARange& range : lba_ranges) for (const NFSLBARange& range : lba_ranges)
@@ -114,7 +114,7 @@ u64 NFSFileReader::CalculateExpectedRawSize(const std::vector<NFSLBARange>& lba_
return sizeof(NFSHeader) + total_blocks * BLOCK_SIZE; return sizeof(NFSHeader) + total_blocks * BLOCK_SIZE;
} }
u64 NFSFileReader::CalculateExpectedDataSize(const std::vector<NFSLBARange>& lba_ranges) u64 NFSFileReader::CalculateExpectedDataSize(std::span<const NFSLBARange> lba_ranges)
{ {
u32 greatest_block_index = 0; u32 greatest_block_index = 0;
for (const NFSLBARange& range : lba_ranges) for (const NFSLBARange& range : lba_ranges)
+3 -2
View File
@@ -6,6 +6,7 @@
#include <array> #include <array>
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -68,8 +69,8 @@ private:
static std::vector<File::DirectIOFile> OpenFiles(const std::string& directory, static std::vector<File::DirectIOFile> OpenFiles(const std::string& directory,
File::DirectIOFile first_file, File::DirectIOFile first_file,
u64 expected_raw_size, u64* raw_size_out); u64 expected_raw_size, u64* raw_size_out);
static u64 CalculateExpectedRawSize(const std::vector<NFSLBARange>& lba_ranges); static u64 CalculateExpectedRawSize(std::span<const NFSLBARange> lba_ranges);
static u64 CalculateExpectedDataSize(const std::vector<NFSLBARange>& lba_ranges); static u64 CalculateExpectedDataSize(std::span<const NFSLBARange> lba_ranges);
NFSFileReader(std::vector<NFSLBARange> lba_ranges, std::vector<File::DirectIOFile> files, Key key, NFSFileReader(std::vector<NFSLBARange> lba_ranges, std::vector<File::DirectIOFile> files, Key key,
u64 raw_size); u64 raw_size);
+2 -2
View File
@@ -218,9 +218,9 @@ std::optional<Disc> ParseString(std::string_view xml, std::string xml_path)
return disc; return disc;
} }
static bool CheckRegion(const std::vector<std::string>& xml_regions, std::string_view game_region) static bool CheckRegion(std::span<const std::string> xml_regions, std::string_view game_region)
{ {
if (xml_regions.begin() == xml_regions.end()) if (xml_regions.empty())
return true; return true;
for (const auto& region : xml_regions) for (const auto& region : xml_regions)
+1 -2
View File
@@ -8,7 +8,6 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <ranges>
#include <span> #include <span>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
@@ -93,7 +92,7 @@ void Volume::AddTMDToSyncHash(Common::SHA1::Context* context, const Partition& p
AddToSyncHash(context, content); AddToSyncHash(context, content);
} }
std::map<Language, std::string> Volume::ReadWiiNames(const std::vector<char16_t>& data) std::map<Language, std::string> Volume::ReadWiiNames(std::span<const char16_t> data)
{ {
std::map<Language, std::string> names; std::map<Language, std::string> names;
for (size_t i = 0; i < NUMBER_OF_LANGUAGES; ++i) for (size_t i = 0; i < NUMBER_OF_LANGUAGES; ++i)
+2 -2
View File
@@ -81,7 +81,7 @@ public:
virtual std::vector<u8> GetContent(u16 index) const { return {}; } virtual std::vector<u8> GetContent(u16 index) const { return {}; }
virtual std::vector<u64> GetContentOffsets() const { return {}; } virtual std::vector<u64> GetContentOffsets() const { return {}; }
virtual bool CheckContentIntegrity(const IOS::ES::Content& content, virtual bool CheckContentIntegrity(const IOS::ES::Content& content,
const std::vector<u8>& encrypted_data, std::span<const u8> encrypted_data,
const IOS::ES::TicketReader& ticket) const const IOS::ES::TicketReader& ticket) const
{ {
return false; return false;
@@ -150,7 +150,7 @@ protected:
void AddTMDToSyncHash(Common::SHA1::Context* context, const Partition& partition) const; void AddTMDToSyncHash(Common::SHA1::Context* context, const Partition& partition) const;
virtual u32 GetOffsetShift() const { return 0; } virtual u32 GetOffsetShift() const { return 0; }
static std::map<Language, std::string> ReadWiiNames(const std::vector<char16_t>& data); static std::map<Language, std::string> ReadWiiNames(std::span<const char16_t> data);
static constexpr size_t NUMBER_OF_LANGUAGES = 10; static constexpr size_t NUMBER_OF_LANGUAGES = 10;
static constexpr size_t NAME_CHARS_LENGTH = 42; static constexpr size_t NAME_CHARS_LENGTH = 42;
+1 -1
View File
@@ -213,7 +213,7 @@ static std::vector<u8> ParseHash(const char* str)
return hash; return hash;
} }
std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const std::vector<u8>& data, std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(std::span<const u8> data,
const std::string& system) const std::string& system)
{ {
pugi::xml_document doc; pugi::xml_document doc;
+1 -1
View File
@@ -85,7 +85,7 @@ private:
static DownloadStatus DownloadDatfile(const std::string& system, DownloadStatus old_status); static DownloadStatus DownloadDatfile(const std::string& system, DownloadStatus old_status);
static std::vector<u8> ReadDatfile(const std::string& system); static std::vector<u8> ReadDatfile(const std::string& system);
std::vector<PotentialMatch> ScanDatfile(const std::vector<u8>& data, const std::string& system); std::vector<PotentialMatch> ScanDatfile(std::span<const u8> data, const std::string& system);
std::string m_game_id; std::string m_game_id;
u16 m_revision = 0; u16 m_revision = 0;
+2 -1
View File
@@ -7,6 +7,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
@@ -149,7 +150,7 @@ std::vector<u64> VolumeWAD::GetContentOffsets() const
} }
bool VolumeWAD::CheckContentIntegrity(const IOS::ES::Content& content, bool VolumeWAD::CheckContentIntegrity(const IOS::ES::Content& content,
const std::vector<u8>& encrypted_data, std::span<const u8> encrypted_data,
const IOS::ES::TicketReader& ticket) const const IOS::ES::TicketReader& ticket) const
{ {
if (encrypted_data.size() != Common::AlignUp(content.size, 0x40)) if (encrypted_data.size() != Common::AlignUp(content.size, 0x40))
+2 -1
View File
@@ -6,6 +6,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -38,7 +39,7 @@ public:
GetCertificateChain(const Partition& partition = PARTITION_NONE) const override; GetCertificateChain(const Partition& partition = PARTITION_NONE) const override;
std::vector<u8> GetContent(u16 index) const override; std::vector<u8> GetContent(u16 index) const override;
std::vector<u64> GetContentOffsets() const override; std::vector<u64> GetContentOffsets() const override;
bool CheckContentIntegrity(const IOS::ES::Content& content, const std::vector<u8>& encrypted_data, bool CheckContentIntegrity(const IOS::ES::Content& content, std::span<const u8> encrypted_data,
const IOS::ES::TicketReader& ticket) const override; const IOS::ES::TicketReader& ticket) const override;
IOS::ES::TicketReader GetTicketWithFixedCommonKey() const override; IOS::ES::TicketReader GetTicketWithFixedCommonKey() const override;
std::string GetGameID(const Partition& partition = PARTITION_NONE) const override; std::string GetGameID(const Partition& partition = PARTITION_NONE) const override;
+1 -1
View File
@@ -860,7 +860,7 @@ size_t WIARVZFileReader<RVZ>::Chunk::GetOutBytesWrittenExcludingExceptions() con
template <bool RVZ> template <bool RVZ>
bool WIARVZFileReader<RVZ>::ApplyHashExceptions( bool WIARVZFileReader<RVZ>::ApplyHashExceptions(
const std::vector<HashExceptionEntry>& exception_list, std::span<const HashExceptionEntry> exception_list,
VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP]) VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP])
{ {
for (const HashExceptionEntry& exception : exception_list) for (const HashExceptionEntry& exception : exception_list)
+1 -1
View File
@@ -242,7 +242,7 @@ private:
WIARVZCompressionType compression_type, u32 exception_lists = 0, WIARVZCompressionType compression_type, u32 exception_lists = 0,
u32 rvz_packed_size = 0, u64 data_offset = 0); u32 rvz_packed_size = 0, u64 data_offset = 0);
static bool ApplyHashExceptions(const std::vector<HashExceptionEntry>& exception_list, static bool ApplyHashExceptions(std::span<const HashExceptionEntry> exception_list,
VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP]); VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP]);
static std::string VersionToString(u32 version); static std::string VersionToString(u32 version);
@@ -45,7 +45,7 @@ void ConfigChoiceU32::OnConfigChanged()
setCurrentIndex(ReadValue(m_setting)); setCurrentIndex(ReadValue(m_setting));
} }
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options, ConfigStringChoice::ConfigStringChoice(std::span<const std::string> options,
const Config::Info<std::string>& setting, const Config::Info<std::string>& setting,
Config::Layer* layer) Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(true) : ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(true)
@@ -57,7 +57,7 @@ ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
connect(this, &QComboBox::currentIndexChanged, this, &ConfigStringChoice::Update); connect(this, &QComboBox::currentIndexChanged, this, &ConfigStringChoice::Update);
} }
ConfigStringChoice::ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options, ConfigStringChoice::ConfigStringChoice(std::span<const std::pair<QString, QString>> options,
const Config::Info<std::string>& setting, const Config::Info<std::string>& setting,
Config::Layer* layer) Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(false) : ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(false)
@@ -85,9 +85,9 @@ class ConfigStringChoice final : public ConfigControl<ToolTipComboBox>
{ {
Q_OBJECT Q_OBJECT
public: public:
ConfigStringChoice(const std::vector<std::string>& options, ConfigStringChoice(std::span<const std::string> options, const Config::Info<std::string>& setting,
const Config::Info<std::string>& setting, Config::Layer* layer = nullptr); Config::Layer* layer = nullptr);
ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options, ConfigStringChoice(std::span<const std::pair<QString, QString>> options,
const Config::Info<std::string>& setting, Config::Layer* layer = nullptr); const Config::Info<std::string>& setting, Config::Layer* layer = nullptr);
void Load(); void Load();
@@ -6,8 +6,8 @@
#include <future> #include <future>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <span>
#include <tuple> #include <tuple>
#include <vector>
#include <QByteArray> #include <QByteArray>
#include <QHBoxLayout> #include <QHBoxLayout>
@@ -129,7 +129,7 @@ void VerifyWidget::ConnectWidgets()
#endif #endif
} }
static void SetHash(QLineEdit* line_edit, const std::vector<u8>& hash) static void SetHash(QLineEdit* line_edit, std::span<const u8> hash)
{ {
const QByteArray byte_array = QByteArray::fromRawData(reinterpret_cast<const char*>(hash.data()), const QByteArray byte_array = QByteArray::fromRawData(reinterpret_cast<const char*>(hash.data()),
static_cast<int>(hash.size())); static_cast<int>(hash.size()));
@@ -4,7 +4,6 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <string>
#include <utility> #include <utility>
#include <QCheckBox> #include <QCheckBox>
@@ -98,7 +98,7 @@ void WiimoteControllersWidget::StartBluetoothAdapterRefresh()
} }
void WiimoteControllersWidget::OnBluetoothAdapterRefreshComplete( void WiimoteControllersWidget::OnBluetoothAdapterRefreshComplete(
const std::vector<USBUtils::DeviceInfo>& devices) std::span<const USBUtils::DeviceInfo> devices)
{ {
const int configured_vid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID); const int configured_vid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID);
const int configured_pid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID); const int configured_pid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID);
@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <array> #include <array>
#include <span>
#include <QWidget> #include <QWidget>
@@ -40,7 +41,7 @@ private:
void OnBluetoothPassthroughDeviceChanged(int index); void OnBluetoothPassthroughDeviceChanged(int index);
void OnBluetoothPassthroughSyncPressed(); void OnBluetoothPassthroughSyncPressed();
void OnBluetoothPassthroughResetPressed(); void OnBluetoothPassthroughResetPressed();
void OnBluetoothAdapterRefreshComplete(const std::vector<USBUtils::DeviceInfo>& devices); void OnBluetoothAdapterRefreshComplete(std::span<const USBUtils::DeviceInfo> devices);
void OnWiimoteRefreshPressed(); void OnWiimoteRefreshPressed();
void OnWiimoteConfigure(size_t index); void OnWiimoteConfigure(size_t index);
void StartBluetoothAdapterRefresh(); void StartBluetoothAdapterRefresh();
+1 -1
View File
@@ -38,7 +38,7 @@ void GBAHost::GameChanged()
}); });
} }
void GBAHost::FrameEnded(const std::vector<u32>& video_buffer) void GBAHost::FrameEnded(std::span<const u32> video_buffer)
{ {
QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, video_buffer] { QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, video_buffer] {
widget_controller->FrameEnded(video_buffer); widget_controller->FrameEnded(video_buffer);
+2 -2
View File
@@ -5,7 +5,7 @@
#ifdef HAS_LIBMGBA #ifdef HAS_LIBMGBA
#include <vector> #include <span>
#include "Core/Host.h" #include "Core/Host.h"
@@ -22,7 +22,7 @@ public:
explicit GBAHost(std::weak_ptr<HW::GBA::Core> core); explicit GBAHost(std::weak_ptr<HW::GBA::Core> core);
~GBAHost() override; ~GBAHost() override;
void GameChanged() override; void GameChanged() override;
void FrameEnded(const std::vector<u32>& video_buffer) override; void FrameEnded(std::span<const u32> video_buffer) override;
private: private:
GBAWidgetController* m_widget_controller{}; GBAWidgetController* m_widget_controller{};
@@ -65,7 +65,7 @@ void ChunkedProgressDialog::ConnectWidgets()
} }
void ChunkedProgressDialog::show(const QString& title, const u64 data_size, void ChunkedProgressDialog::show(const QString& title, const u64 data_size,
const std::vector<int>& players) std::span<const int> players)
{ {
m_progress_box->setTitle(title); m_progress_box->setTitle(title);
m_data_size = data_size; m_data_size = data_size;
@@ -4,7 +4,7 @@
#pragma once #pragma once
#include <map> #include <map>
#include <vector> #include <span>
#include <QDialog> #include <QDialog>
@@ -23,7 +23,7 @@ class ChunkedProgressDialog : public QDialog
public: public:
explicit ChunkedProgressDialog(QWidget* parent); explicit ChunkedProgressDialog(QWidget* parent);
void show(const QString& title, u64 data_size, const std::vector<int>& players); void show(const QString& title, u64 data_size, std::span<const int> players);
void SetProgress(int pid, u64 progress); void SetProgress(int pid, u64 progress);
void reject() override; void reject() override;
@@ -1248,7 +1248,7 @@ void NetPlayDialog::AbortGameDigest()
} }
void NetPlayDialog::ShowChunkedProgressDialog(const std::string& title, const u64 data_size, void NetPlayDialog::ShowChunkedProgressDialog(const std::string& title, const u64 data_size,
const std::vector<int>& players) std::span<const int> players)
{ {
QueueOnObject(this, [this, title, data_size, players] { QueueOnObject(this, [this, title, data_size, players] {
if (m_chunked_progress_dialog->isVisible()) if (m_chunked_progress_dialog->isVisible())
@@ -93,7 +93,7 @@ public:
void AbortGameDigest() override; void AbortGameDigest() override;
void ShowChunkedProgressDialog(const std::string& title, u64 data_size, void ShowChunkedProgressDialog(const std::string& title, u64 data_size,
const std::vector<int>& players) override; std::span<const int> players) override;
void HideChunkedProgressDialog() override; void HideChunkedProgressDialog() override;
void SetChunkedProgress(int pid, u64 progress) override; void SetChunkedProgress(int pid, u64 progress) override;
+4 -4
View File
@@ -5,6 +5,7 @@
#include <chrono> #include <chrono>
#include <numeric> #include <numeric>
#include <span>
#include <string> #include <string>
#include <picojson.h> #include <picojson.h>
@@ -23,14 +24,13 @@ NetPlayIndex::~NetPlayIndex()
Remove(); Remove();
} }
static std::optional<picojson::value> ParseResponse(const std::vector<u8>& response) static std::optional<picojson::value> ParseResponse(std::span<const u8> response)
{ {
const std::string response_string(reinterpret_cast<const char*>(response.data()), const char* data = reinterpret_cast<const char*>(response.data());
response.size());
picojson::value json; picojson::value json;
const auto error = picojson::parse(json, response_string); const auto error = picojson::parse(json, data, data + response.size());
if (!error.empty()) if (!error.empty())
return {}; return {};
+5 -3
View File
@@ -14,7 +14,9 @@
#include <mbedtls/sha256.h> #include <mbedtls/sha256.h>
#include <zlib.h> #include <zlib.h>
#ifdef _WIN32
#include "Common/CommonFuncs.h" #include "Common/CommonFuncs.h"
#endif
#include "Common/CommonPaths.h" #include "Common/CommonPaths.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/HttpRequest.h" #include "Common/HttpRequest.h"
@@ -204,7 +206,7 @@ void TodoList::Log() const
} }
} }
static bool DownloadContent(const std::vector<TodoList::DownloadOp>& to_download, static bool DownloadContent(std::span<const TodoList::DownloadOp> to_download,
const std::string& content_base_url, const std::string& temp_path) const std::string& content_base_url, const std::string& temp_path)
{ {
Common::HttpRequest req(std::chrono::seconds(30), ProgressCallback); Common::HttpRequest req(std::chrono::seconds(30), ProgressCallback);
@@ -337,7 +339,7 @@ static bool BackupFile(const std::string& path)
return true; return true;
} }
static bool DeleteObsoleteFiles(const std::vector<TodoList::DeleteOp>& to_delete, static bool DeleteObsoleteFiles(std::span<const TodoList::DeleteOp> to_delete,
const std::string& install_base_path) const std::string& install_base_path)
{ {
for (const auto& op : to_delete) for (const auto& op : to_delete)
@@ -370,7 +372,7 @@ static bool DeleteObsoleteFiles(const std::vector<TodoList::DeleteOp>& to_delete
return true; return true;
} }
static bool UpdateFiles(const std::vector<TodoList::UpdateOp>& to_update, static bool UpdateFiles(std::span<const TodoList::UpdateOp> to_update,
const std::string& install_base_path, const std::string& temp_path) const std::string& install_base_path, const std::string& temp_path)
{ {
#ifdef _WIN32 #ifdef _WIN32
@@ -161,7 +161,7 @@ bool VertexShaderManager::UseVertexDepthRange()
// Syncs the shader constant buffers with xfmem // Syncs the shader constant buffers with xfmem
// TODO: A cleaner way to control the matrices without making a mess in the parameters field // TODO: A cleaner way to control the matrices without making a mess in the parameters field
void VertexShaderManager::SetConstants(const std::vector<std::string>& textures, void VertexShaderManager::SetConstants(std::span<const std::string> textures,
XFStateManager& xf_state_manager) XFStateManager& xf_state_manager)
{ {
if (constants.missing_color_hex != g_ActiveConfig.iMissingColorValue) if (constants.missing_color_hex != g_ActiveConfig.iMissingColorValue)
@@ -4,10 +4,9 @@
#pragma once #pragma once
#include <array> #include <array>
#include <span>
#include <string> #include <string>
#include <vector>
#include "Common/BitSet.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Matrix.h" #include "Common/Matrix.h"
#include "VideoCommon/ConstantManager.h" #include "VideoCommon/ConstantManager.h"
@@ -26,7 +25,7 @@ public:
// constant management // constant management
void SetProjectionMatrix(XFStateManager& xf_state_manager); void SetProjectionMatrix(XFStateManager& xf_state_manager);
void SetConstants(const std::vector<std::string>& textures, XFStateManager& xf_state_manager); void SetConstants(std::span<const std::string> textures, XFStateManager& xf_state_manager);
// data: 3 floats representing the X, Y and Z vertex model coordinates and the posmatrix index. // 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 // out: 4 floats which will be initialized with the corresponding clip space coordinates
@@ -13,7 +13,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
static bool RoundTrippableDisassemble(const std::vector<u16>& code, std::string& text) static bool RoundTrippableDisassemble(std::span<const u16> code, std::string& text)
{ {
DSP::AssemblerSettings settings; DSP::AssemblerSettings settings;
settings.ext_separator = '\''; settings.ext_separator = '\'';
@@ -29,7 +29,7 @@ static bool RoundTrippableDisassemble(const std::vector<u16>& code, std::string&
// This test goes from text ASM to binary to text ASM and once again back to binary. // This test goes from text ASM to binary to text ASM and once again back to binary.
// Then the two binaries are compared. // Then the two binaries are compared.
static bool RoundTrip(const std::vector<u16>& code1) static bool RoundTrip(std::span<const u16> code1)
{ {
std::vector<u16> code2; std::vector<u16> code2;
std::string text; std::string text;
@@ -90,7 +90,7 @@ static bool SuperTrip(const char* asm_code)
} }
// Assembles asm_code, and verifies that it matches code1. // Assembles asm_code, and verifies that it matches code1.
static bool AssembleAndCompare(const char* asm_code, const std::vector<u16>& code1) static bool AssembleAndCompare(const char* asm_code, std::span<const u16> code1)
{ {
std::vector<u16> code2; std::vector<u16> code2;
if (!DSP::Assemble(asm_code, code2)) if (!DSP::Assemble(asm_code, code2))