mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-12 18:47:57 -05:00
Merge pull request #9508 from ameerj/hle-ipc-buffer-span
hle_ipc: Use std::span to avoid heap allocations/copies when calling ReadBuffer
This commit is contained in:
@ -550,7 +550,7 @@ std::pair<s32, Errno> Socket::RecvFrom(int flags, std::vector<u8>& message, Sock
|
||||
return {-1, GetAndLogLastError()};
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> Socket::Send(const std::vector<u8>& message, int flags) {
|
||||
std::pair<s32, Errno> Socket::Send(std::span<const u8> message, int flags) {
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(flags == 0);
|
||||
|
||||
@ -563,7 +563,7 @@ std::pair<s32, Errno> Socket::Send(const std::vector<u8>& message, int flags) {
|
||||
return {-1, GetAndLogLastError()};
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> Socket::SendTo(u32 flags, const std::vector<u8>& message,
|
||||
std::pair<s32, Errno> Socket::SendTo(u32 flags, std::span<const u8> message,
|
||||
const SockAddrIn* addr) {
|
||||
ASSERT(flags == 0);
|
||||
|
||||
|
@ -182,7 +182,7 @@ std::pair<s32, Errno> ProxySocket::ReceivePacket(int flags, std::vector<u8>& mes
|
||||
return {static_cast<u32>(read_bytes), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> ProxySocket::Send(const std::vector<u8>& message, int flags) {
|
||||
std::pair<s32, Errno> ProxySocket::Send(std::span<const u8> message, int flags) {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(flags == 0);
|
||||
@ -200,7 +200,7 @@ void ProxySocket::SendPacket(ProxyPacket& packet) {
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> ProxySocket::SendTo(u32 flags, const std::vector<u8>& message,
|
||||
std::pair<s32, Errno> ProxySocket::SendTo(u32 flags, std::span<const u8> message,
|
||||
const SockAddrIn* addr) {
|
||||
ASSERT(flags == 0);
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
@ -48,11 +49,11 @@ public:
|
||||
std::pair<s32, Errno> ReceivePacket(int flags, std::vector<u8>& message, SockAddrIn* addr,
|
||||
std::size_t max_length);
|
||||
|
||||
std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags) override;
|
||||
std::pair<s32, Errno> Send(std::span<const u8> message, int flags) override;
|
||||
|
||||
void SendPacket(ProxyPacket& packet);
|
||||
|
||||
std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message,
|
||||
std::pair<s32, Errno> SendTo(u32 flags, std::span<const u8> message,
|
||||
const SockAddrIn* addr) override;
|
||||
|
||||
Errno SetLinger(bool enable, u32 linger) override;
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -66,9 +67,9 @@ public:
|
||||
virtual std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message,
|
||||
SockAddrIn* addr) = 0;
|
||||
|
||||
virtual std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags) = 0;
|
||||
virtual std::pair<s32, Errno> Send(std::span<const u8> message, int flags) = 0;
|
||||
|
||||
virtual std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message,
|
||||
virtual std::pair<s32, Errno> SendTo(u32 flags, std::span<const u8> message,
|
||||
const SockAddrIn* addr) = 0;
|
||||
|
||||
virtual Errno SetLinger(bool enable, u32 linger) = 0;
|
||||
@ -138,9 +139,9 @@ public:
|
||||
|
||||
std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr) override;
|
||||
|
||||
std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags) override;
|
||||
std::pair<s32, Errno> Send(std::span<const u8> message, int flags) override;
|
||||
|
||||
std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message,
|
||||
std::pair<s32, Errno> SendTo(u32 flags, std::span<const u8> message,
|
||||
const SockAddrIn* addr) override;
|
||||
|
||||
Errno SetLinger(bool enable, u32 linger) override;
|
||||
|
Reference in New Issue
Block a user