From 6059f608c0d6a55b0c1154942d83d088322f5558 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Mon, 4 Dec 2023 00:22:36 +0100 Subject: [PATCH] Minor improvements --- src/Nazara/Core/Posix/DynLibImpl.cpp | 7 ++----- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 2 +- tests/UnitTests/Engine/Core/StringExtTest.cpp | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Nazara/Core/Posix/DynLibImpl.cpp b/src/Nazara/Core/Posix/DynLibImpl.cpp index 3ceb72fa7..0d4b6ff3e 100644 --- a/src/Nazara/Core/Posix/DynLibImpl.cpp +++ b/src/Nazara/Core/Posix/DynLibImpl.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -26,11 +27,7 @@ namespace Nz static_assert(sizeof(DynLibFunc) == sizeof(void*)); - // poor man's std::bit_cast - DynLibFunc funcPtr; - std::memcpy(&funcPtr, &ptr, sizeof(funcPtr)); - - return funcPtr; + return std::bit_cast(ptr); } bool DynLibImpl::Load(const std::filesystem::path& libraryPath, std::string* errorMessage) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index c962baef8..a5961df09 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -87,7 +87,7 @@ namespace Nz::GL if (func && wrapErrorHandling) { - if (std::strcmp(funcName, "glGetError") != 0) //< Prevent infinite recursion + if constexpr (FuncIndex != UnderlyingCast(FunctionIndex::glGetError)) //< Prevent infinite recursion { using Wrapper = GLWrapper; func = Wrapper::WrapErrorHandling(); diff --git a/tests/UnitTests/Engine/Core/StringExtTest.cpp b/tests/UnitTests/Engine/Core/StringExtTest.cpp index 4a4edd726..ab2c5fabc 100644 --- a/tests/UnitTests/Engine/Core/StringExtTest.cpp +++ b/tests/UnitTests/Engine/Core/StringExtTest.cpp @@ -79,6 +79,7 @@ SCENARIO("String", "[CORE][STRING]") CHECK(Nz::MatchPattern("Lynix", "?????")); CHECK(Nz::MatchPattern("Lynix", "*Lynix")); CHECK(Nz::MatchPattern("Lynox", "*Lyn?x")); + CHECK_FALSE(Nz::MatchPattern("Lynix", "Lynixx")); CHECK_FALSE(Nz::MatchPattern("Lynix", "Ly")); CHECK_FALSE(Nz::MatchPattern("", "?")); CHECK_FALSE(Nz::MatchPattern("", "*"));