1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Axe BoolToString() in favor of int casts

When I encountered this function, I asked myself, why make a dedicated
function instead of casting to int?

Well, as it turns out, you can't just cast to int, because you have to
convert it to a string by doing help.String(number).c_str(), like all
the other ints. So it's actually more wasteful to do it the normal way
instead of using BoolToString().

That is, until my recent changes came along and made it so that you can
just provide an int and it'll automatically be converted to a string, no
questions asked. Now, it's more optimal to do a straight cast to int
instead of having to go through a middleman function. So this function
is getting axed in favor of casting to int instead.
This commit is contained in:
Misa 2020-09-25 09:11:52 -07:00 committed by Ethan Lee
parent 58795a1381
commit ab446790e8

View file

@ -25,19 +25,6 @@
#define strcasecmp stricmp
#endif
//TODO: Non Urgent code cleanup
const char* BoolToString(bool _b)
{
if(_b)
{
return "1";
}
else
{
return "0";
}
}
bool GetButtonFromString(const char *pText, SDL_GameControllerButton *button)
{
if (*pText == '0' ||
@ -5855,10 +5842,10 @@ std::string Game::writemaingamesave(tinyxml2::XMLDocument& doc)
xml::update_tag(msgs, "companion", companion);
xml::update_tag(msgs, "lastsaved", lastsaved);
xml::update_tag(msgs, "supercrewmate", BoolToString(supercrewmate));
xml::update_tag(msgs, "supercrewmate", (int) supercrewmate);
xml::update_tag(msgs, "scmprogress", scmprogress);
xml::update_tag(msgs, "scmmoveme", BoolToString(scmmoveme));
xml::update_tag(msgs, "scmmoveme", (int) scmmoveme);
xml::update_tag(msgs, "frames", frames);
@ -5873,8 +5860,8 @@ std::string Game::writemaingamesave(tinyxml2::XMLDocument& doc)
xml::update_tag(msgs, "hardestroom", hardestroom.c_str());
xml::update_tag(msgs, "hardestroomdeaths", hardestroomdeaths);
xml::update_tag(msgs, "finalmode", BoolToString(map.finalmode));
xml::update_tag(msgs, "finalstretch", BoolToString(map.finalstretch));
xml::update_tag(msgs, "finalmode", (int) map.finalmode);
xml::update_tag(msgs, "finalstretch", (int) map.finalstretch);
std::string summary = savearea + ", " + timestring();
@ -5988,10 +5975,10 @@ void Game::customsavequick(std::string savfile)
xml::update_tag(msgs, "companion", companion);
xml::update_tag(msgs, "lastsaved", lastsaved);
xml::update_tag(msgs, "supercrewmate", BoolToString(supercrewmate));
xml::update_tag(msgs, "supercrewmate", (int) supercrewmate);
xml::update_tag(msgs, "scmprogress", scmprogress);
xml::update_tag(msgs, "scmmoveme", BoolToString(scmmoveme));
xml::update_tag(msgs, "scmmoveme", (int) scmmoveme);
xml::update_tag(msgs, "frames", frames);
@ -6006,7 +5993,7 @@ void Game::customsavequick(std::string savfile)
xml::update_tag(msgs, "hardestroom", hardestroom.c_str());
xml::update_tag(msgs, "hardestroomdeaths", hardestroomdeaths);
xml::update_tag(msgs, "showminimap", BoolToString(map.customshowmm));
xml::update_tag(msgs, "showminimap", (int) map.customshowmm);
std::string summary = savearea + ", " + timestring();
xml::update_tag(msgs, "summary", summary.c_str());