diff options
| author | Sintendo <3380580+Sintendo@users.noreply.github.com> | 2026-02-01 09:20:46 +0100 |
|---|---|---|
| committer | Sintendo <3380580+Sintendo@users.noreply.github.com> | 2026-03-23 23:55:09 +0100 |
| commit | f6a67aa6e722350db3fc778e4f881cb60090faa1 (patch) | |
| tree | f35cbb126c72e04cc9032aa55453cfa0edcf7a97 /Source/Core/Common | |
| parent | c05b231015375a88ecb4c4eea69862c8c75b809c (diff) | |
Use more std::span arguments
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Assembler/GekkoLexer.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/Common/Assembler/GekkoLexer.h | 3 | ||||
| -rw-r--r-- | Source/Core/Common/Debug/Watches.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/Common/Debug/Watches.h | 3 | ||||
| -rw-r--r-- | Source/Core/Common/HttpRequest.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/Common/HttpRequest.h | 5 | ||||
| -rw-r--r-- | Source/Core/Common/Network.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/Common/Network.h | 10 |
8 files changed, 22 insertions, 13 deletions
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<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; 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 <array> #include <deque> #include <optional> +#include <span> #include <string_view> #include <vector> @@ -166,7 +167,7 @@ public: } 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 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<std::string>& watches) +void Watches::LoadFromStrings(std::span<const std::string> 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 <cstddef> +#include <span> #include <string> #include <vector> @@ -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<std::string>& watches); + void LoadFromStrings(std::span<const std::string> watches); std::vector<std::string> 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<u8>& payload, +HttpRequest::Response HttpRequest::Post(const std::string& url, std::span<const u8> 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 <optional> #include <span> #include <string> +#include <string_view> #include <vector> #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<u8>& payload, const Headers& headers = {}, + Response Post(const std::string& url, std::span<const u8> 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> 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<u8>& data) +DHCPPacket::DHCPPacket(std::span<const u8> data) { if (data.size() < DHCPBody::SIZE) 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) return; @@ -507,7 +507,7 @@ std::vector<u8> DHCPPacket::Build() const { 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()); 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 <array> +#include <initializer_list> #include <optional> +#include <span> #include <string> #include <string_view> #include <type_traits> @@ -183,8 +185,12 @@ static_assert(sizeof(DHCPBody) == DHCPBody::SIZE); struct DHCPPacket { DHCPPacket(); - DHCPPacket(const std::vector<u8>& data); - void AddOption(u8 fnc, const std::vector<u8>& params); + DHCPPacket(std::span<const u8> data); + 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; DHCPBody body; |
