diff --git a/Source/Android/jni/AndroidCommon/AndroidCommon.cpp b/Source/Android/jni/AndroidCommon/AndroidCommon.cpp index 53ef9174f4..204c495d5d 100644 --- a/Source/Android/jni/AndroidCommon/AndroidCommon.cpp +++ b/Source/Android/jni/AndroidCommon/AndroidCommon.cpp @@ -55,7 +55,7 @@ jobjectArray VectorToJStringArray(JNIEnv* env, const std::vector& v bool IsPathAndroidContent(const std::string& uri) { - return StringBeginsWith(uri, "content://"); + return uri.starts_with("content://"); } std::string OpenModeToAndroid(std::string mode) diff --git a/Source/Core/Common/ArmCPUDetect.cpp b/Source/Core/Common/ArmCPUDetect.cpp index 43c0063f78..b55952cf2b 100644 --- a/Source/Core/Common/ArmCPUDetect.cpp +++ b/Source/Core/Common/ArmCPUDetect.cpp @@ -107,7 +107,7 @@ static std::string ReadCpuinfoField(const std::string& field) while (std::getline(file, line)) { - if (!StringBeginsWith(line, field)) + if (!line.starts_with(field)) continue; auto non_tab = line.find_first_not_of("\t", field.length()); if (non_tab == line.npos) diff --git a/Source/Core/Common/Debug/CodeTrace.cpp b/Source/Core/Common/Debug/CodeTrace.cpp index 3eea7a72fc..d1cb913356 100644 --- a/Source/Core/Common/Debug/CodeTrace.cpp +++ b/Source/Core/Common/Debug/CodeTrace.cpp @@ -3,11 +3,11 @@ #include "Common/Debug/CodeTrace.h" +#include #include #include #include "Common/Event.h" -#include "Common/StringUtil.h" #include "Core/Debugger/PPCDebugInterface.h" #include "Core/HW/CPU.h" #include "Core/PowerPC/PowerPC.h" @@ -16,9 +16,8 @@ namespace { bool IsInstructionLoadStore(std::string_view ins) { - return (StringBeginsWith(ins, "l") && !StringBeginsWith(ins, "li")) || - StringBeginsWith(ins, "st") || StringBeginsWith(ins, "psq_l") || - StringBeginsWith(ins, "psq_s"); + return (ins.starts_with('l') && !ins.starts_with("li")) || ins.starts_with("st") || + ins.starts_with("psq_l") || ins.starts_with("psq_s"); } u32 GetMemoryTargetSize(std::string_view instr) @@ -95,7 +94,7 @@ InstructionAttributes CodeTrace::GetInstructionAttributes(const TraceOutput& ins tmp_attributes.memory_target = instruction.memory_target; tmp_attributes.memory_target_size = GetMemoryTargetSize(instr); - if (StringBeginsWith(instr, "st") || StringBeginsWith(instr, "psq_s")) + if (instr.starts_with("st") || instr.starts_with("psq_s")) tmp_attributes.is_store = true; else tmp_attributes.is_load = true; @@ -263,9 +262,8 @@ HitType CodeTrace::TraceLogic(const TraceOutput& current_instr, bool first_hit) // Checks if the intstruction is a type that needs special handling. const auto CompareInstruction = [](std::string_view instruction, const auto& type_compare) { - return std::any_of( - type_compare.begin(), type_compare.end(), - [&instruction](std::string_view s) { return StringBeginsWith(instruction, s); }); + return std::any_of(type_compare.begin(), type_compare.end(), + [&instruction](std::string_view s) { return instruction.starts_with(s); }); }; // Exclusions from updating tracking logic. mt operations are too complex and specialized. @@ -280,12 +278,12 @@ HitType CodeTrace::TraceLogic(const TraceOutput& current_instr, bool first_hit) static const std::array mover{"mr", "fmr"}; // Link register for when r0 gets overwritten - if (StringBeginsWith(instr.instruction, "mflr") && match_reg0) + if (instr.instruction.starts_with("mflr") && match_reg0) { m_reg_autotrack.erase(reg_itr); return HitType::OVERWRITE; } - else if (StringBeginsWith(instr.instruction, "mtlr") && match_reg0) + if (instr.instruction.starts_with("mtlr") && match_reg0) { // LR is not something tracked return HitType::MOVED; diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 983e7d21a0..dfb82712d7 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -171,7 +171,7 @@ bool Delete(const std::string& filename, IfAbsentBehavior behavior) DEBUG_LOG_FMT(COMMON, "Delete: file {}", filename); #ifdef ANDROID - if (StringBeginsWith(filename, "content://")) + if (filename.starts_with("content://")) { const bool success = DeleteAndroidContent(filename); if (!success) @@ -1054,7 +1054,7 @@ void SetUserPath(unsigned int dir_index, std::string path) #endif // Directories should end with a separator, files should not. - while (StringEndsWith(path, "/")) + while (path.ends_with('/')) path.pop_back(); if (path.empty()) return; diff --git a/Source/Core/Common/NandPaths.cpp b/Source/Core/Common/NandPaths.cpp index 00f5eb235a..9b08cd263d 100644 --- a/Source/Core/Common/NandPaths.cpp +++ b/Source/Core/Common/NandPaths.cpp @@ -76,7 +76,7 @@ std::string GetMiiDatabasePath(std::optional from) bool IsTitlePath(const std::string& path, std::optional from, u64* title_id) { std::string expected_prefix = RootUserPath(from) + "/title/"; - if (!StringBeginsWith(path, expected_prefix)) + if (!path.starts_with(expected_prefix)) { return false; } diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index c8d862e424..1bfb54e9f9 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -431,16 +431,6 @@ std::string ReplaceAll(std::string result, std::string_view src, std::string_vie return result; } -bool StringBeginsWith(std::string_view str, std::string_view begin) -{ - return str.size() >= begin.size() && std::equal(begin.begin(), begin.end(), str.begin()); -} - -bool StringEndsWith(std::string_view str, std::string_view end) -{ - return str.size() >= end.size() && std::equal(end.rbegin(), end.rend(), str.rbegin()); -} - void StringPopBackIf(std::string* s, char c) { if (!s->empty() && s->back() == c) diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 620d437f35..cb58f9fa25 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -169,8 +169,6 @@ std::string WithUnifiedPathSeparators(std::string path); // This requires forward slashes to be used for the path separators, even on Windows. std::string PathToFileName(std::string_view path); -bool StringBeginsWith(std::string_view str, std::string_view begin); -bool StringEndsWith(std::string_view str, std::string_view end); void StringPopBackIf(std::string* s, char c); size_t StringUTF8CodePointCount(const std::string& str); diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index ea7f9b3673..a9bbf759da 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -73,7 +73,7 @@ static std::vector ReadM3UFile(const std::string& m3u_path, // This is the UTF-8 representation of U+FEFF. constexpr std::string_view utf8_bom = "\xEF\xBB\xBF"; - if (StringBeginsWith(line, utf8_bom)) + if (line.starts_with(utf8_bom)) { WARN_LOG_FMT(BOOT, "UTF-8 BOM in file: {}", m3u_path); line.erase(0, utf8_bom.length()); diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 552763c8d1..b832b16595 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -643,17 +643,17 @@ std::string GetMemcardPath(std::string configured_filename, ExpansionInterface:: constexpr std::string_view jp_region = "." JAP_DIR; constexpr std::string_view eu_region = "." EUR_DIR; std::optional path_region = std::nullopt; - if (StringEndsWith(name, us_region)) + if (name.ends_with(us_region)) { name = name.substr(0, name.size() - us_region.size()); path_region = DiscIO::Region::NTSC_U; } - else if (StringEndsWith(name, jp_region)) + else if (name.ends_with(jp_region)) { name = name.substr(0, name.size() - jp_region.size()); path_region = DiscIO::Region::NTSC_J; } - else if (StringEndsWith(name, eu_region)) + else if (name.ends_with(eu_region)) { name = name.substr(0, name.size() - eu_region.size()); path_region = DiscIO::Region::PAL; @@ -695,7 +695,7 @@ std::string GetGCIFolderPath(std::string configured_folder, ExpansionInterface:: // If there's no region code just insert one at the end. UnifyPathSeparators(configured_folder); - while (StringEndsWith(configured_folder, "/")) + while (configured_folder.ends_with('/')) configured_folder.pop_back(); constexpr std::string_view us_region = "/" USA_DIR; @@ -703,17 +703,17 @@ std::string GetGCIFolderPath(std::string configured_folder, ExpansionInterface:: constexpr std::string_view eu_region = "/" EUR_DIR; std::string_view base_path = configured_folder; std::optional path_region = std::nullopt; - if (StringEndsWith(base_path, us_region)) + if (base_path.ends_with(us_region)) { base_path = base_path.substr(0, base_path.size() - us_region.size()); path_region = DiscIO::Region::NTSC_U; } - else if (StringEndsWith(base_path, jp_region)) + else if (base_path.ends_with(jp_region)) { base_path = base_path.substr(0, base_path.size() - jp_region.size()); path_region = DiscIO::Region::NTSC_J; } - else if (StringEndsWith(base_path, eu_region)) + else if (base_path.ends_with(eu_region)) { base_path = base_path.substr(0, base_path.size() - eu_region.size()); path_region = DiscIO::Region::PAL; diff --git a/Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp b/Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp index 82ffba3cc9..e8cbf9f3ed 100644 --- a/Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp +++ b/Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp @@ -197,7 +197,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler( INFO_LOG_FMT(SP1, "Received XLink Kai control data: {}", control_msg); // connected;identifier; - if (StringBeginsWith(control_msg, "connected")) + if (control_msg.starts_with("connected")) { NOTICE_LOG_FMT(SP1, "XLink Kai BBA connected"); OSD::AddMessage("XLink Kai BBA connected", 4500); @@ -226,7 +226,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler( } } // disconnected;optional_identifier;optional_message; - else if (StringBeginsWith(control_msg, "disconnected")) + else if (control_msg.starts_with("disconnected")) { NOTICE_LOG_FMT(SP1, "XLink Kai BBA disconnected"); // Show OSD message for 15 seconds to make sure the user sees it @@ -247,7 +247,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler( break; } // keepalive; - else if (StringBeginsWith(control_msg, "keepalive")) + else if (control_msg.starts_with("keepalive")) { DEBUG_LOG_FMT(SP1, "XLink Kai BBA keepalive"); @@ -262,7 +262,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler( } } // message;message_text; - else if (StringBeginsWith(control_msg, "message")) + else if (control_msg.starts_with("message")) { std::string msg = control_msg.substr(8, control_msg.length() - 1); @@ -271,7 +271,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler( OSD::AddMessage(std::move(msg), 15000); } // chat;message_text; - else if (StringBeginsWith(control_msg, "chat")) + else if (control_msg.starts_with("chat")) { std::string msg = control_msg.substr(5, control_msg.length() - 1); @@ -279,7 +279,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler( OSD::AddMessage(std::move(msg), 5000); } // directmessage;message_text; - else if (StringBeginsWith(control_msg, "directmessage")) + else if (control_msg.starts_with("directmessage")) { std::string msg = control_msg.substr(14, control_msg.length() - 1); diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp index f14500d290..25463b5416 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp @@ -67,8 +67,7 @@ CEXIETHERNET::CEXIETHERNET(BBADeviceType type) // Perform sanity check on BBA MAC address, XLink requires the vendor OUI to be Nintendo's and // to be one of the two used for the GameCube. // Don't actually stop the BBA from initializing though - if (!StringBeginsWith(mac_addr_setting, "00:09:bf") && - !StringBeginsWith(mac_addr_setting, "00:17:ab")) + if (!mac_addr_setting.starts_with("00:09:bf") && !mac_addr_setting.starts_with("00:17:ab")) { PanicAlertFmtT( "BBA MAC address {0} invalid for XLink Kai. A valid Nintendo GameCube MAC address " diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp index 15cc6bd762..e5f7e13c07 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp @@ -31,7 +31,7 @@ HostFileSystem::HostFilename HostFileSystem::BuildFilename(const std::string& wi { for (const auto& redirect : m_nand_redirects) { - if (StringBeginsWith(wii_path, redirect.source_path) && + if (wii_path.starts_with(redirect.source_path) && (wii_path.size() == redirect.source_path.size() || wii_path[redirect.source_path.size()] == '/')) { @@ -121,9 +121,9 @@ HostFileSystem::HostFileSystem(const std::string& root_path, std::vector nand_redirects) : m_root_path{root_path}, m_nand_redirects(std::move(nand_redirects)) { - while (StringEndsWith(m_root_path, "/")) + while (m_root_path.ends_with('/')) m_root_path.pop_back(); - File::CreateFullPath(m_root_path + "/"); + File::CreateFullPath(m_root_path + '/'); ResetFst(); LoadFst(); } @@ -493,7 +493,7 @@ bool HostFileSystem::IsFileOpened(const std::string& path) const bool HostFileSystem::IsDirectoryInUse(const std::string& path) const { return std::any_of(m_handles.begin(), m_handles.end(), [&path](const Handle& handle) { - return handle.opened && StringBeginsWith(handle.wii_path, path); + return handle.opened && handle.wii_path.starts_with(path); }); } diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index e69f6591e2..a1e5dd4fcc 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -252,7 +252,7 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad) continue; // Support CodeWarrior and Dolphin map - if (StringEndsWith(line, " section layout\n") || strcmp(temp, ".text") == 0 || + if (std::string_view{line}.ends_with(" section layout\n") || strcmp(temp, ".text") == 0 || strcmp(temp, ".init") == 0) { section_name = temp; @@ -284,7 +284,7 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad) // 3] _stack_addr found as linker generated symbol // ... // 10] EXILock(func, global) found in exi.a EXIBios.c - if (StringEndsWith(temp, "]")) + if (std::string_view{temp}.ends_with(']')) continue; // TODO - Handle/Write a parser for: diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index 49481149a3..5634c7f60f 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -21,9 +21,9 @@ namespace { SignatureDB::HandlerType GetHandlerType(const std::string& file_path) { - if (StringEndsWith(file_path, ".csv")) + if (file_path.ends_with(".csv")) return SignatureDB::HandlerType::CSV; - if (StringEndsWith(file_path, ".mega")) + if (file_path.ends_with(".mega")) return SignatureDB::HandlerType::MEGA; return SignatureDB::HandlerType::DSY; } diff --git a/Source/Core/DiscIO/RiivolutionParser.cpp b/Source/Core/DiscIO/RiivolutionParser.cpp index dacbbbcfc5..656cd20697 100644 --- a/Source/Core/DiscIO/RiivolutionParser.cpp +++ b/Source/Core/DiscIO/RiivolutionParser.cpp @@ -53,7 +53,7 @@ static std::vector ReadHexString(std::string_view sv) { if ((sv.size() % 2) == 1) return {}; - if (StringBeginsWith(sv, "0x") || StringBeginsWith(sv, "0X")) + if (sv.starts_with("0x") || sv.starts_with("0X")) sv = sv.substr(2); std::vector result; @@ -245,7 +245,7 @@ bool Disc::IsValidForGame(const std::string& game_id, std::optional revisio const int disc_number_int = std::optional(disc_number).value_or(-1); const int revision_int = std::optional(revision).value_or(-1); - if (m_game_filter.m_game && !StringBeginsWith(game_id_full, *m_game_filter.m_game)) + if (m_game_filter.m_game && !game_id_full.starts_with(*m_game_filter.m_game)) return false; if (m_game_filter.m_developer && game_developer != *m_game_filter.m_developer) return false; @@ -276,7 +276,7 @@ std::vector Disc::GeneratePatches(const std::string& game_id) const bool replaced = false; for (const auto& r : replacements) { - if (StringBeginsWith(sv, r.first)) + if (sv.starts_with(r.first)) { for (char c : r.second) result.push_back(c); diff --git a/Source/Core/DiscIO/RiivolutionPatcher.cpp b/Source/Core/DiscIO/RiivolutionPatcher.cpp index 840acf768b..eb0ca53137 100644 --- a/Source/Core/DiscIO/RiivolutionPatcher.cpp +++ b/Source/Core/DiscIO/RiivolutionPatcher.cpp @@ -64,13 +64,13 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ return std::nullopt; #endif - std::string result = StringBeginsWith(external_relative_path, "/") ? m_sd_root : m_patch_root; + std::string result = external_relative_path.starts_with('/') ? m_sd_root : m_patch_root; std::string_view work = external_relative_path; // Strip away all leading and trailing path separators. - while (StringBeginsWith(work, "/")) + while (work.starts_with('/')) work.remove_prefix(1); - while (StringEndsWith(work, "/")) + while (work.ends_with('/')) work.remove_suffix(1); size_t depth = 0; while (true) @@ -126,7 +126,7 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ work = work.substr(separator_position + 1); // Remove any potential extra path separators. - while (StringBeginsWith(work, "/")) + while (work.starts_with('/')) work = work.substr(1); } return result; @@ -425,9 +425,9 @@ static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder, return std::string(b); if (b.empty()) return std::string(a); - if (StringEndsWith(a, "/")) + if (a.ends_with('/')) a.remove_suffix(1); - if (StringBeginsWith(b, "/")) + if (b.starts_with('/')) b.remove_prefix(1); return fmt::format("{}/{}", a, b); }; diff --git a/Source/Core/DiscIO/VolumeVerifier.cpp b/Source/Core/DiscIO/VolumeVerifier.cpp index c6392d446b..855142143f 100644 --- a/Source/Core/DiscIO/VolumeVerifier.cpp +++ b/Source/Core/DiscIO/VolumeVerifier.cpp @@ -247,7 +247,7 @@ std::vector RedumpVerifier::ScanDatfile(const st if (version % 0x30 != m_revision % 0x30) continue; - if (serials.empty() || StringBeginsWith(serials, "DS")) + if (serials.empty() || serials.starts_with("DS")) { // GC Datel discs have no serials in Redump, Wii Datel discs have serials like "DS000101" if (!m_game_id.empty()) @@ -666,7 +666,7 @@ bool VolumeVerifier::CheckPartition(const Partition& partition) { std::string file_name = f.GetName(); Common::ToLower(&file_name); - if (StringBeginsWith(file_name, correct_ios)) + if (file_name.starts_with(correct_ios)) { has_correct_ios = true; break; @@ -865,13 +865,13 @@ void VolumeVerifier::CheckMisc() bool inconsistent_game_id = true; if (game_id_encrypted == "RELSAB") { - if (StringBeginsWith(game_id_unencrypted, "410")) + if (game_id_unencrypted.starts_with("410")) { // This is the Wii Backup Disc (aka "pinkfish" disc), // which legitimately has an inconsistent game ID. inconsistent_game_id = false; } - else if (StringBeginsWith(game_id_unencrypted, "010")) + else if (game_id_unencrypted.starts_with("010")) { // Hacked version of the Wii Backup Disc (aka "pinkfish" disc). std::string proper_game_id = game_id_unencrypted; @@ -1016,7 +1016,7 @@ void VolumeVerifier::CheckMisc() "though the files are not identical.")); } - if (IsDisc(m_volume.GetVolumeType()) && StringBeginsWith(game_id_unencrypted, "R8P")) + if (IsDisc(m_volume.GetVolumeType()) && game_id_unencrypted.starts_with("R8P")) CheckSuperPaperMario(); } diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index af24232406..77d73a8eff 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -235,17 +235,16 @@ u32 CodeViewWidget::AddressForRow(int row) const static bool IsBranchInstructionWithLink(std::string_view ins) { - return StringEndsWith(ins, "l") || StringEndsWith(ins, "la") || StringEndsWith(ins, "l+") || - StringEndsWith(ins, "la+") || StringEndsWith(ins, "l-") || StringEndsWith(ins, "la-"); + return ins.ends_with('l') || ins.ends_with("la") || ins.ends_with("l+") || ins.ends_with("la+") || + ins.ends_with("l-") || ins.ends_with("la-"); } static bool IsInstructionLoadStore(std::string_view ins) { // Could add check for context address being near PC, because we need gprs to be correct for the // load/store. - return (StringBeginsWith(ins, "l") && !StringBeginsWith(ins, "li")) || - StringBeginsWith(ins, "st") || StringBeginsWith(ins, "psq_l") || - StringBeginsWith(ins, "psq_s"); + return (ins.starts_with('l') && !ins.starts_with("li")) || ins.starts_with("st") || + ins.starts_with("psq_l") || ins.starts_with("psq_s"); } void CodeViewWidget::Update() diff --git a/Source/Core/DolphinQt/Settings/GameCubePane.cpp b/Source/Core/DolphinQt/Settings/GameCubePane.cpp index 1454a907f4..7b7bac989d 100644 --- a/Source/Core/DolphinQt/Settings/GameCubePane.cpp +++ b/Source/Core/DolphinQt/Settings/GameCubePane.cpp @@ -526,7 +526,7 @@ bool GameCubePane::SetGCIFolder(ExpansionInterface::Slot slot, const QString& pa std::string raw_path = WithUnifiedPathSeparators(QFileInfo(path).absoluteFilePath().toStdString()); - while (StringEndsWith(raw_path, "/")) + while (raw_path.ends_with('/')) raw_path.pop_back(); // The user might be attempting to reset this path to its default, check for this. diff --git a/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp b/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp index d55284a65a..0111947608 100644 --- a/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp @@ -642,7 +642,7 @@ void Init(const std::string& game_id) { hasbind = true; type = BIND_AXIS; - if (StringBeginsWith(value, "Device ''")) + if (value.starts_with("Device ''")) sscanf(value.c_str(), "Device ''-Axis %d%c", &bindnum, &modifier); else sscanf(value.c_str(), "Device '%127[^\']'-Axis %d%c", dev, &bindnum, &modifier); @@ -651,7 +651,7 @@ void Init(const std::string& game_id) { hasbind = true; type = BIND_BUTTON; - if (StringBeginsWith(value, "Device ''")) + if (value.starts_with("Device ''")) sscanf(value.c_str(), "Device ''-Button %d", &bindnum); else sscanf(value.c_str(), "Device '%127[^\']'-Button %d", dev, &bindnum); diff --git a/Source/UnitTests/Common/StringUtilTest.cpp b/Source/UnitTests/Common/StringUtilTest.cpp index 8cc3590a7c..1f1159d1eb 100644 --- a/Source/UnitTests/Common/StringUtilTest.cpp +++ b/Source/UnitTests/Common/StringUtilTest.cpp @@ -16,30 +16,6 @@ TEST(StringUtil, JoinStrings) EXPECT_EQ("???", JoinStrings({"?", "?"}, "?")); } -TEST(StringUtil, StringBeginsWith) -{ - EXPECT_TRUE(StringBeginsWith("abc", "a")); - EXPECT_FALSE(StringBeginsWith("abc", "b")); - EXPECT_TRUE(StringBeginsWith("abc", "ab")); - EXPECT_FALSE(StringBeginsWith("a", "ab")); - EXPECT_FALSE(StringBeginsWith("", "a")); - EXPECT_FALSE(StringBeginsWith("", "ab")); - EXPECT_TRUE(StringBeginsWith("abc", "")); - EXPECT_TRUE(StringBeginsWith("", "")); -} - -TEST(StringUtil, StringEndsWith) -{ - EXPECT_TRUE(StringEndsWith("abc", "c")); - EXPECT_FALSE(StringEndsWith("abc", "b")); - EXPECT_TRUE(StringEndsWith("abc", "bc")); - EXPECT_FALSE(StringEndsWith("a", "ab")); - EXPECT_FALSE(StringEndsWith("", "a")); - EXPECT_FALSE(StringEndsWith("", "ab")); - EXPECT_TRUE(StringEndsWith("abc", "")); - EXPECT_TRUE(StringEndsWith("", "")); -} - TEST(StringUtil, StringPopBackIf) { std::string abc = "abc";