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

Remove reference from customlevelclass::load arg

For some reason, originally, this function mutated the std::string
passed into it by reference. So calling the function could potentially
mutate whatever got passed in, and callers potentially could have relied
on that behavior.

Now that the surrounding callsites have all been cleaned up, though
(especially scriptclass::startgamemode), it's clear that it's only used
in two places: Loading the level in the editor, and loading the level in
live gameplay. In both cases, the passed-in string isn't used ever again
afterwards.

So, it's safe to delete the mutable reference without any undesirable
effects, making the code cleaner and easier to understand. The function
now mutates a copy instead of mutating whatever the caller has.
This commit is contained in:
Misa 2023-03-16 21:09:41 -07:00
parent 79f5e7a05c
commit acfa085fd1
2 changed files with 2 additions and 2 deletions

View file

@ -987,7 +987,7 @@ int customlevelclass::findwarptoken(int t)
}
bool customlevelclass::load(std::string& _path)
bool customlevelclass::load(std::string _path)
{
tinyxml2::XMLDocument doc;
tinyxml2::XMLHandle hDoc(&doc);

View file

@ -137,7 +137,7 @@ public:
int absfree(int x, int y);
bool load(std::string& _path);
bool load(std::string _path);
#ifndef NO_EDITOR
bool save(const std::string& _path);
#endif