summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/config/project_settings.cpp2
-rw-r--r--core/templates/local_vector.h4
-rw-r--r--drivers/vulkan/rendering_device_driver_vulkan.cpp2
-rw-r--r--editor/editor_property_name_processor.cpp2
-rw-r--r--editor/multi_node_edit.h2
-rw-r--r--modules/csg/csg.cpp2
-rw-r--r--modules/navigation/3d/godot_navigation_server_3d.cpp2
-rw-r--r--modules/navigation/nav_map.cpp4
-rw-r--r--scene/main/viewport.cpp4
-rw-r--r--servers/physics_3d/godot_shape_3d.cpp2
-rw-r--r--servers/physics_3d/godot_soft_body_3d.cpp4
-rw-r--r--tests/core/templates/test_local_vector.h11
12 files changed, 27 insertions, 14 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index ee20aea35d..a0412e91ff 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -253,7 +253,7 @@ bool ProjectSettings::get_ignore_value_in_docs(const String &p_name) const {
}
void ProjectSettings::add_hidden_prefix(const String &p_prefix) {
- ERR_FAIL_COND_MSG(hidden_prefixes.find(p_prefix) > -1, vformat("Hidden prefix '%s' already exists.", p_prefix));
+ ERR_FAIL_COND_MSG(hidden_prefixes.has(p_prefix), vformat("Hidden prefix '%s' already exists.", p_prefix));
hidden_prefixes.push_back(p_prefix);
}
diff --git a/core/templates/local_vector.h b/core/templates/local_vector.h
index e0047e0782..c281d70d92 100644
--- a/core/templates/local_vector.h
+++ b/core/templates/local_vector.h
@@ -264,6 +264,10 @@ public:
return -1;
}
+ bool has(const T &p_val) const {
+ return find(p_val) != -1;
+ }
+
template <typename C>
void sort_custom() {
U len = count;
diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp
index 339d0782bf..131e0e4a8a 100644
--- a/drivers/vulkan/rendering_device_driver_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp
@@ -2603,7 +2603,7 @@ Error RenderingDeviceDriverVulkan::swap_chain_resize(CommandQueueID p_cmd_queue,
break;
}
- bool present_mode_available = present_modes.find(present_mode) >= 0;
+ bool present_mode_available = present_modes.has(present_mode);
if (present_mode_available) {
print_verbose("Using present mode: " + present_mode_name);
} else {
diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp
index 1318b84d60..a00b50c191 100644
--- a/editor/editor_property_name_processor.cpp
+++ b/editor/editor_property_name_processor.cpp
@@ -75,7 +75,7 @@ String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const
Vector<String> parts = p_name.split("_", false);
for (int i = 0; i < parts.size(); i++) {
// Articles/conjunctions/prepositions which should only be capitalized when not at beginning and end.
- if (i > 0 && i + 1 < parts.size() && stop_words.find(parts[i]) != -1) {
+ if (i > 0 && i + 1 < parts.size() && stop_words.has(parts[i])) {
continue;
}
HashMap<String, String>::ConstIterator remap = capitalize_string_remaps.find(parts[i]);
diff --git a/editor/multi_node_edit.h b/editor/multi_node_edit.h
index 000d41c4c1..32fe7402fd 100644
--- a/editor/multi_node_edit.h
+++ b/editor/multi_node_edit.h
@@ -73,7 +73,7 @@ public:
return false;
}
for (int i = 0; i < get_node_count(); i++) {
- if (nodes.find(p_other->get_node(i)) == -1) {
+ if (!nodes.has(p_other->get_node(i))) {
return false;
}
}
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index 878664bb9c..cec03b7246 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -1098,7 +1098,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
};
// Check if edge has already been processed.
- if (processed_edges.find(edge_points_and_uvs) != -1) {
+ if (processed_edges.has(edge_points_and_uvs)) {
continue;
}
diff --git a/modules/navigation/3d/godot_navigation_server_3d.cpp b/modules/navigation/3d/godot_navigation_server_3d.cpp
index 61a128e004..6cbfd93088 100644
--- a/modules/navigation/3d/godot_navigation_server_3d.cpp
+++ b/modules/navigation/3d/godot_navigation_server_3d.cpp
@@ -136,7 +136,7 @@ bool GodotNavigationServer3D::map_is_active(RID p_map) const {
NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_NULL_V(map, false);
- return active_maps.find(map) >= 0;
+ return active_maps.has(map);
}
COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp
index a3f2ee2e61..dfbc92a919 100644
--- a/modules/navigation/nav_map.cpp
+++ b/modules/navigation/nav_map.cpp
@@ -734,7 +734,7 @@ void NavMap::remove_link(NavLink *p_link) {
}
bool NavMap::has_agent(NavAgent *agent) const {
- return (agents.find(agent) >= 0);
+ return agents.has(agent);
}
void NavMap::add_agent(NavAgent *agent) {
@@ -754,7 +754,7 @@ void NavMap::remove_agent(NavAgent *agent) {
}
bool NavMap::has_obstacle(NavObstacle *obstacle) const {
- return (obstacles.find(obstacle) >= 0);
+ return obstacles.has(obstacle);
}
void NavMap::add_obstacle(NavObstacle *obstacle) {
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 06cdc02213..b8c691c6e7 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2374,7 +2374,7 @@ void Viewport::_gui_hide_control(Control *p_control) {
if (gui.key_focus == p_control) {
gui_release_focus();
}
- if (gui.mouse_over == p_control || gui.mouse_over_hierarchy.find(p_control) >= 0) {
+ if (gui.mouse_over == p_control || gui.mouse_over_hierarchy.has(p_control)) {
_drop_mouse_over(p_control->get_parent_control());
}
if (gui.drag_mouse_over == p_control) {
@@ -2394,7 +2394,7 @@ void Viewport::_gui_remove_control(Control *p_control) {
if (gui.key_focus == p_control) {
gui.key_focus = nullptr;
}
- if (gui.mouse_over == p_control || gui.mouse_over_hierarchy.find(p_control) >= 0) {
+ if (gui.mouse_over == p_control || gui.mouse_over_hierarchy.has(p_control)) {
_drop_mouse_over(p_control->get_parent_control());
}
if (gui.drag_mouse_over == p_control) {
diff --git a/servers/physics_3d/godot_shape_3d.cpp b/servers/physics_3d/godot_shape_3d.cpp
index 6eb983d5e0..70b6bcf19e 100644
--- a/servers/physics_3d/godot_shape_3d.cpp
+++ b/servers/physics_3d/godot_shape_3d.cpp
@@ -1133,7 +1133,7 @@ void GodotConvexPolygonShape3D::_setup(const Vector<Vector3> &p_vertices) {
max_support = s;
}
}
- if (extreme_vertices.find(best_vertex) == -1)
+ if (!extreme_vertices.has(best_vertex))
extreme_vertices.push_back(best_vertex);
}
}
diff --git a/servers/physics_3d/godot_soft_body_3d.cpp b/servers/physics_3d/godot_soft_body_3d.cpp
index e621977326..fd9141f46e 100644
--- a/servers/physics_3d/godot_soft_body_3d.cpp
+++ b/servers/physics_3d/godot_soft_body_3d.cpp
@@ -626,11 +626,11 @@ void GodotSoftBody3D::generate_bending_constraints(int p_distance) {
for (Link &link : links) {
const int ia = (int)(link.n[0] - &nodes[0]);
const int ib = (int)(link.n[1] - &nodes[0]);
- if (node_links[ia].find(ib) == -1) {
+ if (!node_links[ia].has(ib)) {
node_links[ia].push_back(ib);
}
- if (node_links[ib].find(ia) == -1) {
+ if (!node_links[ib].has(ia)) {
node_links[ib].push_back(ia);
}
}
diff --git a/tests/core/templates/test_local_vector.h b/tests/core/templates/test_local_vector.h
index 2873a9a028..c9544c625b 100644
--- a/tests/core/templates/test_local_vector.h
+++ b/tests/core/templates/test_local_vector.h
@@ -63,7 +63,7 @@ TEST_CASE("[LocalVector] Push Back.") {
CHECK(vector[4] == 4);
}
-TEST_CASE("[LocalVector] Find.") {
+TEST_CASE("[LocalVector] Find, has.") {
LocalVector<int> vector;
vector.push_back(3);
vector.push_back(1);
@@ -85,6 +85,15 @@ TEST_CASE("[LocalVector] Find.") {
CHECK(vector.find(-1) == -1);
CHECK(vector.find(5) == -1);
+
+ CHECK(vector.has(0));
+ CHECK(vector.has(1));
+ CHECK(vector.has(2));
+ CHECK(vector.has(3));
+ CHECK(vector.has(4));
+
+ CHECK(!vector.has(-1));
+ CHECK(!vector.has(5));
}
TEST_CASE("[LocalVector] Remove.") {