mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use const auto & instead of making a copy
parent
91d22f7617
commit
a23dda7ffe
|
@ -205,7 +205,7 @@ static bool IsSameScript(const ContentInfo *ci, bool md5sum, ScriptInfo *info, S
|
||||||
if (!md5sum) return true;
|
if (!md5sum) return true;
|
||||||
|
|
||||||
ScriptFileChecksumCreator checksum(dir);
|
ScriptFileChecksumCreator checksum(dir);
|
||||||
auto tar_filename = info->GetTarFile();
|
const auto &tar_filename = info->GetTarFile();
|
||||||
TarList::iterator iter;
|
TarList::iterator iter;
|
||||||
if (!tar_filename.empty() && (iter = _tar_list[dir].find(tar_filename)) != _tar_list[dir].end()) {
|
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
|
/* The main script is in a tar file, so find all files that
|
||||||
|
|
|
@ -189,7 +189,7 @@ size_t OneOfManySettingDesc::ParseSingleValue(const char *str, size_t len, const
|
||||||
if (isdigit(*str)) return std::strtoul(str, nullptr, 0);
|
if (isdigit(*str)) return std::strtoul(str, nullptr, 0);
|
||||||
|
|
||||||
size_t idx = 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;
|
if (one.size() == len && strncmp(one.c_str(), str, len) == 0) return idx;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ static void SurveySettingsTable(nlohmann::json &survey, const SettingTable &tabl
|
||||||
/* Skip any old settings we no longer save/load. */
|
/* Skip any old settings we no longer save/load. */
|
||||||
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
|
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;
|
if (skip_if_default && sd->IsDefaultValue(object)) continue;
|
||||||
survey[name] = sd->FormatValue(object);
|
survey[name] = sd->FormatValue(object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ TEST_CASE("PartialPixelSlopeAdditionTest - A half tile steep slope is a one corn
|
||||||
* @param expected The expect partial pixels Z values.
|
* @param expected The expect partial pixels Z values.
|
||||||
* @return True iff at all GetPartialPixelZ results are the same as the expected Z-coordinates.
|
* @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++) {
|
for (uint i = 0; i < expected.size(); i++) {
|
||||||
int actual = GetPartialPixelZ(GB(i, 4, 4), GB(i, 0, 4), slope);
|
int actual = GetPartialPixelZ(GB(i, 4, 4), GB(i, 0, 4), slope);
|
||||||
|
|
|
@ -1599,7 +1599,7 @@ public:
|
||||||
{
|
{
|
||||||
if (src.empty()) return src;
|
if (src.empty()) return src;
|
||||||
|
|
||||||
const auto specs = HouseSpec::Specs();
|
const auto &specs = HouseSpec::Specs();
|
||||||
std::set<PickerItem> dst;
|
std::set<PickerItem> dst;
|
||||||
for (const auto &item : src) {
|
for (const auto &item : src) {
|
||||||
if (item.grfid == 0) {
|
if (item.grfid == 0) {
|
||||||
|
|
Loading…
Reference in New Issue