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:
bunnei
2023-01-30 12:17:09 -08:00
committed by GitHub
61 changed files with 368 additions and 326 deletions

View File

@ -755,11 +755,12 @@ Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
return hid_core.GetSupportedStyleTag();
}
void Controller_NPad::SetSupportedNpadIdTypes(u8* data, std::size_t length) {
void Controller_NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
const auto length = data.size();
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
supported_npad_id_types.clear();
supported_npad_id_types.resize(length / sizeof(u32));
std::memcpy(supported_npad_id_types.data(), data, length);
std::memcpy(supported_npad_id_types.data(), data.data(), length);
}
void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {

View File

@ -6,6 +6,7 @@
#include <array>
#include <atomic>
#include <mutex>
#include <span>
#include "common/bit_field.h"
#include "common/common_types.h"
@ -95,7 +96,7 @@ public:
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
void SetSupportedNpadIdTypes(u8* data, std::size_t length);
void SetSupportedNpadIdTypes(std::span<const u8> data);
void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
std::size_t GetSupportedNpadIdTypesSize() const;