From 932645f2453472ed8a89702b641299c2817e52da Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Fri, 19 Apr 2024 14:24:34 -0400 Subject: [PATCH] Apply modernize-use-starts-ends-with --- Source/Core/Core/IOS/ES/ES.cpp | 6 +++--- Source/Core/Core/IOS/FS/HostBackend/FS.cpp | 2 +- Source/Core/Core/IOS/IOS.cpp | 6 +++--- Source/Core/UICommon/ResourcePack/ResourcePack.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index 810353a893..216821cfbd 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -1017,11 +1017,11 @@ bool ESCore::IsIssuerCorrect(VerifyContainerType type, const ES::CertReader& iss switch (type) { case VerifyContainerType::TMD: - return issuer_cert.GetName().compare(0, 2, "CP") == 0; + return issuer_cert.GetName().starts_with("CP"); case VerifyContainerType::Ticket: - return issuer_cert.GetName().compare(0, 2, "XS") == 0; + return issuer_cert.GetName().starts_with("XS"); case VerifyContainerType::Device: - return issuer_cert.GetName().compare(0, 2, "MS") == 0; + return issuer_cert.GetName().starts_with("MS"); default: return false; } diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp index 699e333db1..8ef5af6f71 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp @@ -43,7 +43,7 @@ HostFileSystem::HostFilename HostFileSystem::BuildFilename(const std::string& wi } } - if (wii_path.compare(0, 1, "/") == 0) + if (wii_path.starts_with("/")) return HostFilename{m_root_path + Common::EscapePath(wii_path), false}; ASSERT_MSG(IOS_FS, false, "Invalid Wii path '{}' given to BuildFilename()", wii_path); diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index 2f96cc99bb..b2a0a25b05 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -673,16 +673,16 @@ std::optional EmulationKernel::OpenDevice(OpenRequest& request) request.fd = new_fd; std::shared_ptr device; - if (request.path.find("/dev/usb/oh0/") == 0 && !GetDeviceByName(request.path) && + if (request.path.starts_with("/dev/usb/oh0/") && !GetDeviceByName(request.path) && !HasFeature(GetVersion(), Feature::NewUSB)) { device = std::make_shared(*this, request.path); } - else if (request.path.find("/dev/") == 0) + else if (request.path.starts_with("/dev/")) { device = GetDeviceByName(request.path); } - else if (request.path.find('/') == 0) + else if (request.path.starts_with('/')) { device = GetDeviceByName("/dev/fs"); } diff --git a/Source/Core/UICommon/ResourcePack/ResourcePack.cpp b/Source/Core/UICommon/ResourcePack/ResourcePack.cpp index 7f670e7748..223c33e0ea 100644 --- a/Source/Core/UICommon/ResourcePack/ResourcePack.cpp +++ b/Source/Core/UICommon/ResourcePack/ResourcePack.cpp @@ -88,7 +88,7 @@ ResourcePack::ResourcePack(const std::string& path) : m_path(path) unzGetCurrentFileInfo64(file, &texture_info, filename.data(), static_cast(filename.size()), nullptr, 0, nullptr, 0); - if (filename.compare(0, 9, "textures/") != 0 || texture_info.uncompressed_size == 0) + if (!filename.starts_with("textures/") || texture_info.uncompressed_size == 0) continue; // If a texture is compressed and the manifest doesn't state that, abort.