mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-09-25 04:12:17 -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:
@@ -21,17 +21,31 @@
|
||||
#include <malloc.h>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class PluginData {
|
||||
public:
|
||||
explicit PluginData(const std::vector<uint8_t> &buffer, std::string source);
|
||||
explicit PluginData(std::vector<uint8_t> &&buffer, std::string_view source) : mBuffer(std::move(buffer)), mSource(source) {
|
||||
}
|
||||
|
||||
uint32_t getHandle() {
|
||||
explicit PluginData(std::span<uint8_t> buffer, std::string_view source) : mBuffer(buffer.begin(), buffer.end()), mSource(source) {
|
||||
}
|
||||
|
||||
[[nodiscard]] uint32_t getHandle() const {
|
||||
return (uint32_t) this;
|
||||
}
|
||||
|
||||
size_t length = 0;
|
||||
std::unique_ptr<uint8_t[]> buffer;
|
||||
[[nodiscard]] std::span<uint8_t const> getBuffer() const {
|
||||
return mBuffer;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::string &getSource() const {
|
||||
return mSource;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> mBuffer;
|
||||
std::string mSource;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user