Codechange: Use range-for iteration.

This commit is contained in:
Peter Nelson
2023-05-07 12:09:54 +01:00
committed by PeterN
parent cef3a2570d
commit e6740046ee
22 changed files with 169 additions and 193 deletions

View File

@@ -51,8 +51,8 @@ void FlowMapper::Run(LinkGraphJob &job) const
* division by 0 if spawn date == last compression date. This matches
* LinkGraph::Monthly(). */
uint runtime = job.JoinDate() - job.Settings().recalc_time - job.LastCompression() + 1;
for (FlowStatMap::iterator i = flows.begin(); i != flows.end(); ++i) {
i->second.ScaleToMonthly(runtime);
for (auto &it : flows) {
it.second.ScaleToMonthly(runtime);
}
}
/* Clear paths. */

View File

@@ -273,14 +273,14 @@ void LinkGraphOverlay::Draw(const DrawPixelInfo *dpi)
void LinkGraphOverlay::DrawLinks(const DrawPixelInfo *dpi) const
{
int width = ScaleGUITrad(this->scale);
for (LinkMap::const_iterator i(this->cached_links.begin()); i != this->cached_links.end(); ++i) {
if (!Station::IsValidID(i->first)) continue;
Point pta = this->GetStationMiddle(Station::Get(i->first));
for (StationLinkMap::const_iterator j(i->second.begin()); j != i->second.end(); ++j) {
if (!Station::IsValidID(j->first)) continue;
Point ptb = this->GetStationMiddle(Station::Get(j->first));
for (const auto &i : this->cached_links) {
if (!Station::IsValidID(i.first)) continue;
Point pta = this->GetStationMiddle(Station::Get(i.first));
for (const auto &j : i.second) {
if (!Station::IsValidID(j.first)) continue;
Point ptb = this->GetStationMiddle(Station::Get(j.first));
if (!this->IsLinkVisible(pta, ptb, dpi, width + 2)) continue;
this->DrawContent(pta, ptb, j->second);
this->DrawContent(pta, ptb, j.second);
}
}
}
@@ -319,13 +319,13 @@ void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &c
void LinkGraphOverlay::DrawStationDots(const DrawPixelInfo *dpi) const
{
int width = ScaleGUITrad(this->scale);
for (StationSupplyList::const_iterator i(this->cached_stations.begin()); i != this->cached_stations.end(); ++i) {
const Station *st = Station::GetIfValid(i->first);
for (const auto &i : this->cached_stations) {
const Station *st = Station::GetIfValid(i.first);
if (st == nullptr) continue;
Point pt = this->GetStationMiddle(st);
if (!this->IsPointVisible(pt, dpi, 3 * width)) continue;
uint r = width * 2 + width * 2 * std::min(200U, i->second) / 200;
uint r = width * 2 + width * 2 * std::min(200U, i.second) / 200;
LinkGraphOverlay::DrawVertex(pt.x, pt.y, r,
_colour_gradient[st->owner != OWNER_NONE ?

View File

@@ -110,8 +110,8 @@ void LinkGraphSchedule::JoinNext()
*/
void LinkGraphSchedule::SpawnAll()
{
for (JobList::iterator i = this->running.begin(); i != this->running.end(); ++i) {
(*i)->SpawnThread();
for (auto &it : this->running) {
it->SpawnThread();
}
}
@@ -120,8 +120,8 @@ void LinkGraphSchedule::SpawnAll()
*/
/* static */ void LinkGraphSchedule::Clear()
{
for (JobList::iterator i(instance.running.begin()); i != instance.running.end(); ++i) {
(*i)->AbortJob();
for (auto &it : instance.running) {
it->AbortJob();
}
instance.running.clear();
instance.schedule.clear();

View File

@@ -144,10 +144,10 @@ bool LinkRefresher::HandleRefit(CargoID refit_cargo)
*/
void LinkRefresher::ResetRefit()
{
for (RefitList::iterator it(this->refit_capacities.begin()); it != this->refit_capacities.end(); ++it) {
if (it->remaining == it->capacity) continue;
this->capacities[it->cargo] += it->capacity - it->remaining;
it->remaining = it->capacity;
for (auto &it : this->refit_capacities) {
if (it.remaining == it.capacity) continue;
this->capacities[it.cargo] += it.capacity - it.remaining;
it.remaining = it.capacity;
}
}