Skip to content

Commit 6741aa7

Browse files
committed
Remove vanilla::ends_with in favor of C++20 ends_with
1 parent 703f105 commit 6741aa7

4 files changed

Lines changed: 3 additions & 10 deletions

File tree

source/ham/appdata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ const char* EscapeBinDirectory() {
349349
perror("EscapeBinDirectory: getcwd");
350350
ham_strcpy(bin_dir_buf, ".");
351351
}
352-
if (vanilla::ends_with(bin_dir_buf, "/build/install") || vanilla::ends_with(bin_dir_buf, "\\build\\install")) {
352+
if (std::string_view(bin_dir_buf).ends_with("/build/install") || std::string_view(bin_dir_buf).ends_with("\\build\\install")) {
353353
if (chdir("../..") < 0) {
354354
perror("EscapeBinDirectory: chdir");
355355
}

source/launcher/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ struct Launcher
557557
void CopyToAddonsFolder(std::string_view addonsFolder, std::string_view sourcePath)
558558
{
559559
// .zip files only
560-
if (!vanilla::ends_with(sourcePath, ".zip"))
560+
if (!sourcePath.ends_with(".zip"))
561561
{
562562
return;
563563
}

source/vanilla_extract/include/vfs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ struct SDL_IOStream;
1414

1515
namespace vanilla
1616
{
17-
bool ends_with(std::string_view haystack, std::string_view suffix);
18-
1917
struct CaseInsensitive
2018
{
2119
bool operator() (const std::string& lhs, const std::string& rhs) const;

source/vanilla_extract/src/vfs.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ namespace vanilla {
1212
// ----------------------------------------------------------------------------
1313
// Simple helpers
1414

15-
bool ends_with(std::string_view lhs, std::string_view rhs)
16-
{
17-
return lhs.size() >= rhs.size() && lhs.compare(lhs.size() - rhs.size(), std::string_view::npos, rhs) == 0;
18-
}
19-
2015
bool vanilla::CaseInsensitive::operator() (const std::string& lhs, const std::string& rhs) const
2116
{
2217
return strcasecmp(lhs.c_str(), rhs.c_str()) < 0;
@@ -153,7 +148,7 @@ static void list_dir_inner(std::string_view prefix, Vfs* vfs, const char* direct
153148
continue;
154149

155150
each.insert(0, prefix);
156-
if (ends_with(each, TOMBSTONE_SUFFIX))
151+
if (each.ends_with(TOMBSTONE_SUFFIX))
157152
{
158153
each.erase(each.size() - TOMBSTONE_SUFFIX.size());
159154
output->erase(each);

0 commit comments

Comments
 (0)