mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-09-20 09:49:58 -05:00
- use const auto& where possible
- avoid using const std::unique_ptr& and const std::shared_ptr& - avoid wrapping results in std::optional - prefer std::string_view over const std::string& - update FSUtils::LoadFileToMem to write into std::vector<uint8_t> - use std::span when possible - Avoid unnessecary copies in PluginDataFactory - allocate plugins as HeapMemoryFixedSize which bascially is a std::unique_ptr with fixed size
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
#include "PluginData.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
PluginData::PluginData(const std::vector<uint8_t> &input, std::string source) : length(input.size()), mSource(std::move(source)) {
|
||||
auto data_copy = make_unique_nothrow<uint8_t[]>(length);
|
||||
if (!data_copy) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate space on default heap");
|
||||
this->length = 0;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Allocated %d kb on default heap", length / 1024);
|
||||
memcpy(data_copy.get(), &input[0], length);
|
||||
this->buffer = std::move(data_copy);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user