1
0
Fork 0

Codechange: use const auto & instead of making a copy

pull/13772/head
Rubidium 2025-03-08 20:42:02 +01:00 committed by rubidium42
parent 91d22f7617
commit a23dda7ffe
5 changed files with 5 additions and 5 deletions

View File

@ -205,7 +205,7 @@ static bool IsSameScript(const ContentInfo *ci, bool md5sum, ScriptInfo *info, S
if (!md5sum) return true;
ScriptFileChecksumCreator checksum(dir);
auto tar_filename = info->GetTarFile();
const auto &tar_filename = info->GetTarFile();
TarList::iterator iter;
if (!tar_filename.empty() && (iter = _tar_list[dir].find(tar_filename)) != _tar_list[dir].end()) {
/* The main script is in a tar file, so find all files that

View File

@ -189,7 +189,7 @@ size_t OneOfManySettingDesc::ParseSingleValue(const char *str, size_t len, const
if (isdigit(*str)) return std::strtoul(str, nullptr, 0);
size_t idx = 0;
for (auto one : many) {
for (const auto &one : many) {
if (one.size() == len && strncmp(one.c_str(), str, len) == 0) return idx;
idx++;
}

View File

@ -146,7 +146,7 @@ static void SurveySettingsTable(nlohmann::json &survey, const SettingTable &tabl
/* Skip any old settings we no longer save/load. */
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
auto name = sd->GetName();
const auto &name = sd->GetName();
if (skip_if_default && sd->IsDefaultValue(object)) continue;
survey[name] = sd->FormatValue(object);
}

View File

@ -85,7 +85,7 @@ TEST_CASE("PartialPixelSlopeAdditionTest - A half tile steep slope is a one corn
* @param expected The expect partial pixels Z values.
* @return True iff at all GetPartialPixelZ results are the same as the expected Z-coordinates.
*/
bool CheckPartialPixelZ(Slope slope, std::array<int, TILE_SIZE * TILE_SIZE> expected)
bool CheckPartialPixelZ(Slope slope, const std::array<int, TILE_SIZE * TILE_SIZE> &expected)
{
for (uint i = 0; i < expected.size(); i++) {
int actual = GetPartialPixelZ(GB(i, 4, 4), GB(i, 0, 4), slope);

View File

@ -1599,7 +1599,7 @@ public:
{
if (src.empty()) return src;
const auto specs = HouseSpec::Specs();
const auto &specs = HouseSpec::Specs();
std::set<PickerItem> dst;
for (const auto &item : src) {
if (item.grfid == 0) {