Refactor endsWith() to not use the STL

There's not really any reason for this function to use heap-allocated
strings. So I've refactored it to not do that.

I would've used SDL_strrstr(), if it existed. It does not appear to
exist. But that's okay.
This commit is contained in:
Misa
2021-02-26 15:29:37 -08:00
committed by Ethan Lee
parent 3171a97160
commit 5d4c1b7e9d
4 changed files with 11 additions and 11 deletions

View File

@@ -82,7 +82,7 @@ static void levelZipCallback(const char* filename)
{
std::string filename_ = filename;
if (endsWith(filename_, ".zip"))
if (endsWith(filename_.c_str(), ".zip"))
{
PHYSFS_File* zip = PHYSFS_openRead(filename_.c_str());
@@ -1822,7 +1822,7 @@ bool editorclass::load(std::string& _path)
// the linefeed + the extremely specific amount of
// whitespace at the end of the contents.
if (endsWith(text, "\n ")) // linefeed + exactly 12 spaces
if (endsWith(text.c_str(), "\n ")) // linefeed + exactly 12 spaces
{
// 12 spaces + 1 linefeed = 13 chars
text = text.substr(0, text.length()-13);