From 642d981acf5c208877523da3567ff30bc9d3645f Mon Sep 17 00:00:00 2001 From: Thibaut PONCHON Date: Sat, 21 Jan 2023 18:39:29 -0500 Subject: [PATCH] Replace std::strcmp by std::string_view::operator== clang-format validation pass Remove unecessary cstring include --- examples/vulkan/Vulkan.cpp | 6 +++--- src/SFML/Window/DRM/DRMContext.cpp | 2 +- src/SFML/Window/GlContext.cpp | 2 +- src/SFML/Window/Unix/VulkanImplX11.cpp | 5 ++--- src/SFML/Window/Win32/VulkanImplWin32.cpp | 5 ++--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/vulkan/Vulkan.cpp b/examples/vulkan/Vulkan.cpp index 76167185..a1b7f486 100644 --- a/examples/vulkan/Vulkan.cpp +++ b/examples/vulkan/Vulkan.cpp @@ -470,11 +470,11 @@ public: // -- VK_LAYER_GOOGLE_unique_objects // These layers perform error checking and warn about bad or sub-optimal Vulkan API usage // VK_LAYER_LUNARG_monitor appends an FPS counter to the window title - if (!std::strcmp(layer.layerName, "VK_LAYER_LUNARG_standard_validation")) + if (std::string_view(layer.layerName) == "VK_LAYER_LUNARG_standard_validation") { validationLayers.push_back("VK_LAYER_LUNARG_standard_validation"); } - else if (!std::strcmp(layer.layerName, "VK_LAYER_LUNARG_monitor")) + else if (std::string_view(layer.layerName) == "VK_LAYER_LUNARG_monitor") { validationLayers.push_back("VK_LAYER_LUNARG_monitor"); } @@ -611,7 +611,7 @@ public: for (VkExtensionProperties& extension : extensions) { - if (!std::strcmp(extension.extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME)) + if (std::string_view(extension.extensionName) == VK_KHR_SWAPCHAIN_EXTENSION_NAME) { supportsSwapchain = true; break; diff --git a/src/SFML/Window/DRM/DRMContext.cpp b/src/SFML/Window/DRM/DRMContext.cpp index 6a014f0a..99468e7d 100644 --- a/src/SFML/Window/DRM/DRMContext.cpp +++ b/src/SFML/Window/DRM/DRMContext.cpp @@ -365,7 +365,7 @@ int initDrm(sf::priv::Drm& drm, const char* device, const char* modeStr, unsigne { drmModeModeInfoPtr currentMode = &connector->modes[i]; - if (std::strcmp(currentMode->name, modeStr) == 0) + if (std::string_view(currentMode->name) == modeStr) { if (vrefresh == 0 || currentMode->vrefresh == vrefresh) { diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index 7ce9c082..5fec8676 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -932,7 +932,7 @@ void GlContext::checkSettings(const ContextSettings& requestedSettings) const if (vendorName && rendererName) { - if ((std::strcmp(vendorName, "Microsoft Corporation") == 0) && (std::strcmp(rendererName, "GDI Generic") == 0)) + if (std::string_view(vendorName) == "Microsoft Corporation" && std::string_view(rendererName) == "GDI Generic") { err() << "Warning: Detected \"Microsoft Corporation GDI Generic\" OpenGL implementation" << '\n' << "The current OpenGL implementation is not hardware-accelerated" << std::endl; diff --git a/src/SFML/Window/Unix/VulkanImplX11.cpp b/src/SFML/Window/Unix/VulkanImplX11.cpp index 94590975..a9b479af 100644 --- a/src/SFML/Window/Unix/VulkanImplX11.cpp +++ b/src/SFML/Window/Unix/VulkanImplX11.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -139,11 +138,11 @@ bool VulkanImplX11::isAvailable(bool requireGraphics) for (const VkExtensionProperties& properties : extensionProperties) { - if (!std::strcmp(properties.extensionName, VK_KHR_SURFACE_EXTENSION_NAME)) + if (std::string_view(properties.extensionName) == VK_KHR_SURFACE_EXTENSION_NAME) { hasVkKhrSurface = true; } - else if (!std::strcmp(properties.extensionName, VK_KHR_XLIB_SURFACE_EXTENSION_NAME)) + else if (std::string_view(properties.extensionName) == VK_KHR_XLIB_SURFACE_EXTENSION_NAME) { hasVkKhrPlatformSurface = true; } diff --git a/src/SFML/Window/Win32/VulkanImplWin32.cpp b/src/SFML/Window/Win32/VulkanImplWin32.cpp index a026face..f6828785 100644 --- a/src/SFML/Window/Win32/VulkanImplWin32.cpp +++ b/src/SFML/Window/Win32/VulkanImplWin32.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include #define VK_USE_PLATFORM_WIN32_KHR @@ -138,11 +137,11 @@ bool VulkanImplWin32::isAvailable(bool requireGraphics) for (const VkExtensionProperties& properties : extensionProperties) { - if (!std::strcmp(properties.extensionName, VK_KHR_SURFACE_EXTENSION_NAME)) + if (std::string_view(properties.extensionName) == VK_KHR_SURFACE_EXTENSION_NAME) { hasVkKhrSurface = true; } - else if (!std::strcmp(properties.extensionName, VK_KHR_WIN32_SURFACE_EXTENSION_NAME)) + else if (std::string_view(properties.extensionName) == VK_KHR_WIN32_SURFACE_EXTENSION_NAME) { hasVkKhrPlatformSurface = true; }