From 8c917d45707eb3151cb64845635df750b10f1027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 26 Sep 2022 18:54:43 +0200 Subject: [PATCH] Clean up unnecessary STL usage in internal converter utilities. --- .../Implementation/converterUtilities.h | 23 +++++++++---------- src/Magnum/SceneTools/sceneconverter.cpp | 1 + src/Magnum/Test/ConverterUtilitiesTest.cpp | 1 + 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Magnum/Implementation/converterUtilities.h b/src/Magnum/Implementation/converterUtilities.h index 435e099bd..70aed6747 100644 --- a/src/Magnum/Implementation/converterUtilities.h +++ b/src/Magnum/Implementation/converterUtilities.h @@ -25,11 +25,10 @@ DEALINGS IN THE SOFTWARE. */ +#include #include #include #include -#include -#include #include "Magnum/Magnum.h" @@ -38,14 +37,14 @@ namespace Magnum { namespace Implementation { /* Used only in executables where we don't want it to be exported */ namespace { -void setOptions(PluginManager::AbstractPlugin& plugin, const std::string& anyPluginName, const std::string& options) { - for(const std::string& option: Utility::String::splitWithoutEmptyParts(options, ',')) { - auto keyValue = Utility::String::partition(option, '='); - Utility::String::trimInPlace(keyValue[0]); - Utility::String::trimInPlace(keyValue[2]); +void setOptions(PluginManager::AbstractPlugin& plugin, const Containers::StringView anyPluginName, const Containers::StringView options) { + for(const Containers::StringView option: options.splitWithoutEmptyParts(',')) { + auto keyValue = option.partition('='); + keyValue[0] = keyValue[0].trimmed(); + keyValue[2] = keyValue[2].trimmed(); - std::vector keyParts = Utility::String::split(keyValue[0], '/'); - CORRADE_INTERNAL_ASSERT(!keyParts.empty()); + const Containers::Array keyParts = keyValue[0].split('/'); + CORRADE_INTERNAL_ASSERT(!keyParts.isEmpty()); Utility::ConfigurationGroup* group = &plugin.configuration(); bool groupNotRecognized = false; for(std::size_t i = 0; i != keyParts.size() - 1; ++i) { @@ -72,10 +71,10 @@ void setOptions(PluginManager::AbstractPlugin& plugin, const std::string& anyPlu /* If the option doesn't have an =, treat it as a boolean flag that's set to true. While there's no similar way to do an inverse, it's still nicer than causing a fatal error with those. */ - if(keyValue[1].empty()) - group->setValue(keyParts.back(), true); - else + if(keyValue[1]) group->setValue(keyParts.back(), keyValue[2]); + else + group->setValue(keyParts.back(), true); } } diff --git a/src/Magnum/SceneTools/sceneconverter.cpp b/src/Magnum/SceneTools/sceneconverter.cpp index d9310ed93..cb67576e4 100644 --- a/src/Magnum/SceneTools/sceneconverter.cpp +++ b/src/Magnum/SceneTools/sceneconverter.cpp @@ -31,6 +31,7 @@ #include /** @todo remove once Arguments is std::string-free */ #include #include +#include /* parseNumberSequence() */ #include "Magnum/MeshTools/Concatenate.h" #include "Magnum/MeshTools/Reference.h" diff --git a/src/Magnum/Test/ConverterUtilitiesTest.cpp b/src/Magnum/Test/ConverterUtilitiesTest.cpp index e825673f9..64d01f5c2 100644 --- a/src/Magnum/Test/ConverterUtilitiesTest.cpp +++ b/src/Magnum/Test/ConverterUtilitiesTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "Magnum/Implementation/converterUtilities.h"