- 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:
Maschell
2023-11-04 15:32:45 +01:00
parent baee1afda3
commit cc5acd0980
37 changed files with 477 additions and 583 deletions

View File

@@ -26,12 +26,12 @@
class WUPSConfig {
public:
explicit WUPSConfig(const std::string &name) {
explicit WUPSConfig(std::string_view name) {
this->name = name;
}
~WUPSConfig() {
for (auto &element : categories) {
for (const auto &element : categories) {
delete element;
}
}
@@ -52,7 +52,7 @@ public:
\return On success, the created and inserted category will be returned.
**/
std::optional<WUPSConfigCategory *> addCategory(const std::string &categoryName) {
std::optional<WUPSConfigCategory *> addCategory(std::string_view categoryName) {
auto curCat = new (std::nothrow) WUPSConfigCategory(categoryName);
if (curCat == nullptr) {
return {};

View File

@@ -24,12 +24,12 @@
class WUPSConfigCategory {
public:
explicit WUPSConfigCategory(const std::string &name) {
explicit WUPSConfigCategory(std::string_view name) {
this->name = name;
}
~WUPSConfigCategory() {
for (auto &element : items) {
for (const auto &element : items) {
delete element;
}
}

View File

@@ -30,7 +30,7 @@ public:
Sets the display name of this WUPSConfigItem
This is the value which will be shown in the configuration menu.
**/
virtual void setDisplayName(const std::string &_displayName) {
virtual void setDisplayName(std::string_view _displayName) {
this->displayName = _displayName;
}
@@ -47,7 +47,7 @@ public:
to be unique in the context of this WUPSConfig.
Items in different categories are NOT allowed to have the config ID.
**/
virtual void setConfigID(const std::string &_configID) {
virtual void setConfigID(std::string_view _configID) {
this->configID = _configID;
}
@@ -162,7 +162,7 @@ public:
return defaultValue != getCurrentValueDisplay();
}
WUPSConfigItem(const std::string &_configID, const std::string &_displayName, WUPSConfigCallbacks_t callbacks, void *_context) {
WUPSConfigItem(std::string_view _configID, std::string_view _displayName, WUPSConfigCallbacks_t callbacks, void *_context) {
this->configID = _configID;
this->displayName = _displayName;
this->context = _context;