From acfa085fd14861062635392ab2336581fca8b416 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 16 Mar 2023 21:09:41 -0700 Subject: [PATCH] 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. --- desktop_version/src/CustomLevels.cpp | 2 +- desktop_version/src/CustomLevels.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index eef6f884..2c93581e 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -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); diff --git a/desktop_version/src/CustomLevels.h b/desktop_version/src/CustomLevels.h index 13f6c79d..73d7d33c 100644 --- a/desktop_version/src/CustomLevels.h +++ b/desktop_version/src/CustomLevels.h @@ -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