10 changes: 5 additions & 5 deletions Source/Core/DiscIO/VolumeVerifier.cpp
Expand Up @@ -247,7 +247,7 @@ std::vector<RedumpVerifier::PotentialMatch> 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())
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down
9 changes: 4 additions & 5 deletions Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/Settings/GameCubePane.cpp
Expand Up @@ -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.
Expand Down
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
24 changes: 0 additions & 24 deletions Source/UnitTests/Common/StringUtilTest.cpp
Expand Up @@ -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";
Expand Down