Optimize out a lot of std::string construction and allocations (#415)

Update CommandLineParameters.hpp

Update CommandLineParametersTests.cpp

Update WebContext.hpp

xmake check-files -f

Fix MaterialPassRegistry
This commit is contained in:
Jérôme Leclercq
2023-12-30 14:50:57 +01:00
committed by GitHub
parent f7c9060364
commit 79ec135af7
57 changed files with 219 additions and 210 deletions

View File

@@ -8,9 +8,8 @@
#define NAZARA_CORE_COMMANDLINEPARAMETERS_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <NazaraUtils/Algorithm.hpp>
#include <string>
#include <string_view>
#include <NazaraUtils/StringHash.hpp>
#include <NazaraUtils/TypeTraits.hpp>
#include <unordered_map>
#include <unordered_set>
@@ -19,9 +18,9 @@ namespace Nz
class CommandLineParameters
{
public:
inline bool GetParameter(const std::string& name, std::string_view* value) const;
inline bool GetParameter(std::string_view name, std::string_view* value) const;
inline bool HasFlag(const std::string& flag) const;
inline bool HasFlag(std::string_view flag) const;
inline bool operator==(const CommandLineParameters& params) const;
inline bool operator!=(const CommandLineParameters& params) const;
@@ -30,8 +29,8 @@ namespace Nz
static inline CommandLineParameters Parse(int argc, const Pointer<const char>* argv);
private:
std::unordered_map<std::string, std::string> m_parameters;
std::unordered_set<std::string> m_flags;
std::unordered_map<std::string, std::string, StringHash<>, std::equal_to<>> m_parameters;
std::unordered_set<std::string, StringHash<>, std::equal_to<>> m_flags;
};
}