Codechange: Use std::ranges::find where possible.

Replace `std::find(range.begin(), range.end(), ...)` with `std::ranges::find(range, ...)`.
This commit is contained in:
Peter Nelson
2024-11-10 10:51:26 +00:00
committed by Peter Nelson
parent 1f18894408
commit 3be0166801
31 changed files with 45 additions and 46 deletions

View File

@@ -373,7 +373,7 @@ static inline void VisitAdjacentWaterRegionPatchNeighbors(const WaterRegionPatch
const TileIndex neighbor_edge_tile = GetEdgeTileCoordinate(nx, ny, opposite_side, x_or_y);
const TWaterRegionPatchLabel neighbor_label = neighboring_region.GetLabel(neighbor_edge_tile);
assert(neighbor_label != INVALID_WATER_REGION_PATCH);
if (std::find(unique_labels.begin(), unique_labels.end(), neighbor_label) == unique_labels.end()) unique_labels.push_back(neighbor_label);
if (std::ranges::find(unique_labels, neighbor_label) == unique_labels.end()) unique_labels.push_back(neighbor_label);
}
for (TWaterRegionPatchLabel unique_label : unique_labels) func(WaterRegionPatchDesc{ nx, ny, unique_label });
}

View File

@@ -151,8 +151,7 @@ public:
TrackFollower F(Yapf().GetVehicle());
if (F.Follow(old_node.key.tile, old_node.key.td)) {
if (this->water_region_corridor.empty()
|| std::find(this->water_region_corridor.begin(), this->water_region_corridor.end(),
GetWaterRegionInfo(F.new_tile)) != this->water_region_corridor.end()) {
|| std::ranges::find(this->water_region_corridor, GetWaterRegionInfo(F.new_tile)) != this->water_region_corridor.end()) {
Yapf().AddMultipleNodes(&old_node, F);
}
}
@@ -255,7 +254,7 @@ public:
while (node->parent) {
const WaterRegionPatchDesc node_water_patch = GetWaterRegionPatchInfo(node->GetTile());
const bool node_water_patch_on_high_level_path = std::find(high_level_path.begin(), high_level_path.end(), node_water_patch) != high_level_path.end();
const bool node_water_patch_on_high_level_path = std::ranges::find(high_level_path, node_water_patch) != high_level_path.end();
const bool add_full_path = !is_intermediate_destination && node_water_patch != end_water_patch;
/* The cached path must always lead to a region patch that's on the high level path.

View File

@@ -95,7 +95,7 @@ public:
bool HasOrigin(const WaterRegionPatchDesc &water_region_patch)
{
return std::find(this->origin_keys.begin(), this->origin_keys.end(), CYapfRegionPatchNodeKey{ water_region_patch }) != this->origin_keys.end();
return std::ranges::find(this->origin_keys, CYapfRegionPatchNodeKey{ water_region_patch }) != this->origin_keys.end();
}
void PfSetStartupNodes()