summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/build_vehicle_gui.cpp2
-rw-r--r--src/core/smallvec_type.hpp13
-rw-r--r--src/hotkeys.cpp4
-rw-r--r--src/network/network_content.cpp5
-rw-r--r--src/rail.cpp2
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/vehicle_cmd.cpp2
-rw-r--r--src/vehicle_gui.cpp11
8 files changed, 16 insertions, 25 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index ce3ebeff4..a118b1c99 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1207,7 +1207,7 @@ struct BuildVehicleWindow : Window {
this->eng_list.Filter(this->cargo_filter[this->cargo_filter_criteria]);
if (0 == this->eng_list.size()) { // no engine passed through the filter, invalidate the previously selected engine
this->SelectEngine(INVALID_ENGINE);
- } else if (!this->eng_list.Contains(this->sel_engine)) { // previously selected engine didn't pass the filter, select the first engine of the list
+ } else if (std::find(this->eng_list.begin(), this->eng_list.end(), this->sel_engine) == this->eng_list.end()) { // previously selected engine didn't pass the filter, select the first engine of the list
this->SelectEngine(this->eng_list[0]);
}
}
diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp
index 5225d13da..9df015ad8 100644
--- a/src/core/smallvec_type.hpp
+++ b/src/core/smallvec_type.hpp
@@ -115,17 +115,6 @@ public:
}
/**
- * Tests whether a item is present in the vector.
- * The '!=' operator of T is used for comparison.
- * @param item Item to test for
- * @return true iff the item is present
- */
- inline bool Contains(const T &item) const
- {
- return std::find(std::vector<T>::begin(), std::vector<T>::end(), item) != std::vector<T>::end();
- }
-
- /**
* Removes given item from this vector
* @param item item to remove
* @note it has to be pointer to item in this map. It is overwritten by the last item.
@@ -145,7 +134,7 @@ public:
*/
inline bool Include(const T &item)
{
- bool is_member = this->Contains(item);
+ bool is_member = std::find(std::vector<T>::begin(), std::vector<T>::end(), item) != std::vector<T>::end();
if (!is_member) *this->Append() = item;
return is_member;
}
diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp
index 9f323bc28..24e6b6c41 100644
--- a/src/hotkeys.cpp
+++ b/src/hotkeys.cpp
@@ -301,7 +301,9 @@ void HotkeyList::Save(IniFile *ini) const
int HotkeyList::CheckMatch(uint16 keycode, bool global_only) const
{
for (const Hotkey *list = this->items; list->name != NULL; ++list) {
- if (list->keycodes.Contains(keycode | WKC_GLOBAL_HOTKEY) || (!global_only && list->keycodes.Contains(keycode))) {
+ auto begin = list->keycodes.begin();
+ auto end = list->keycodes.end();
+ if (std::find(begin, end, keycode | WKC_GLOBAL_HOTKEY) != end || (!global_only && std::find(begin, end, keycode) != end)) {
return list->num;
}
}
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 8c038796f..54798f4b7 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -794,10 +794,9 @@ void ClientNetworkContentSocketHandler::SendReceive()
void ClientNetworkContentSocketHandler::DownloadContentInfo(ContentID cid)
{
/* When we tried to download it already, don't try again */
- if (this->requested.Contains(cid)) return;
+ if (std::find(this->requested.begin(), this->requested.end(), cid) != this->requested.end()) return;
- *this->requested.Append() = cid;
- assert(this->requested.Contains(cid));
+ this->requested.push_back(cid);
this->RequestContentList(1, &cid);
}
diff --git a/src/rail.cpp b/src/rail.cpp
index 8bd7aa518..c97dfb53c 100644
--- a/src/rail.cpp
+++ b/src/rail.cpp
@@ -304,7 +304,7 @@ RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels)
/* Test if any rail type defines the label as an alternate. */
for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) {
const RailtypeInfo *rti = GetRailTypeInfo(r);
- if (rti->alternate_labels.Contains(label)) return r;
+ if (std::find(rti->alternate_labels.begin(), rti->alternate_labels.end(), label) != rti->alternate_labels.end()) return r;
}
}
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index fddfe780d..36a58e62e 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -2150,7 +2150,7 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
if (!T::IsValidID(sid)) return false;
T *st = T::Get(sid);
- if (st->owner != _local_company || _stations_nearby_list.Contains(sid)) return false;
+ if (st->owner != _local_company || std::find(_stations_nearby_list.begin(), _stations_nearby_list.end(), sid) != _stations_nearby_list.end()) return false;
if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST).Succeeded()) {
*_stations_nearby_list.Append() = sid;
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index ccc9446a0..636aadb49 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -355,7 +355,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
/* Reset actual_subtype for every new vehicle */
if (!v->IsArticulatedPart()) actual_subtype = new_subtype;
- if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index) && !only_this) continue;
+ if (v->type == VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->index) == vehicles_to_refit.end() && !only_this) continue;
const Engine *e = v->GetEngine();
if (!e->CanCarryCargo()) continue;
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 6dd4bef33..4a42d746d 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -267,7 +267,7 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t
StringID subtype = GetCargoSubtypeText(v);
if (subtype == STR_EMPTY) break;
- if (!subtypes.Contains(subtype)) continue;
+ if (std::find(subtypes.begin(), subtypes.end(), subtype) == subtypes.end()) continue;
/* We found something matching. */
ret_refit_cyc = refit_cyc;
@@ -414,7 +414,7 @@ struct RefitWindow : public Window {
GetVehicleSet(vehicles_to_refit, Vehicle::Get(this->selected_vehicle), this->num_vehicles);
do {
- if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index)) continue;
+ if (v->type == VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->index) == vehicles_to_refit.end()) continue;
const Engine *e = v->GetEngine();
CargoTypes cmask = e->info.refit_mask;
byte callback_mask = e->info.callback_mask;
@@ -747,14 +747,15 @@ struct RefitWindow : public Window {
for (Train *u = Train::From(v); u != NULL; u = u->Next()) {
/* Start checking. */
- if (vehicles_to_refit.Contains(u->index) && left == INT32_MIN) {
+ const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end();
+ if (contained && left == INT32_MIN) {
left = x - this->hscroll->GetPosition() + r.left + this->vehicle_margin;
width = 0;
}
/* Draw a selection. */
- if ((!vehicles_to_refit.Contains(u->index) || u->Next() == NULL) && left != INT32_MIN) {
- if (u->Next() == NULL && vehicles_to_refit.Contains(u->index)) {
+ if ((!contained || u->Next() == NULL) && left != INT32_MIN) {
+ if (u->Next() == NULL && contained) {
int current_width = u->GetDisplayImageWidth();
width += current_width;
x += current_width;