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

const&-ify getcolorfromname and getcrewmanfromname

This brings these functions into conforming code style and is a small
performance optimization.
This commit is contained in:
Misa 2023-03-07 23:05:43 -08:00
parent f23e99820f
commit 0edf0016d9

View file

@ -131,7 +131,7 @@ void scriptclass::tokenize( const std::string& t )
} }
} }
static int getcolorfromname(std::string name) static int getcolorfromname(const std::string& name)
{ {
if (name == "player") return CYAN; if (name == "player") return CYAN;
else if (name == "cyan") return CYAN; else if (name == "cyan") return CYAN;
@ -149,7 +149,7 @@ static int getcolorfromname(std::string name)
return color; // Last effort to give a valid color, maybe they just input the color? return color; // Last effort to give a valid color, maybe they just input the color?
} }
static int getcrewmanfromname(std::string name) static int getcrewmanfromname(const std::string& name)
{ {
if (name == "player") return obj.getplayer(); // Return the player if (name == "player") return obj.getplayer(); // Return the player
int color = getcolorfromname(name); // Maybe they passed in a crewmate name, or an id? int color = getcolorfromname(name); // Maybe they passed in a crewmate name, or an id?