Skip to content

Commit a0dbdcc

Browse files
Replace find with contains/has where applicable
* Replaces `find(...) != -1` with `contains` for `String` * Replaces `find(...) == -1` with `!contains` for `String` * Replaces `find(...) != -1` with `has` for containers * Replaces `find(...) == -1` with `!has` for containers
1 parent 281fe39 commit a0dbdcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+219
-219
lines changed

core/debugger/engine_debugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, co
137137
script_debugger = memnew(ScriptDebugger);
138138
// Tell the OS that we want to handle termination signals.
139139
OS::get_singleton()->initialize_debugging();
140-
} else if (p_uri.find("://") >= 0) {
140+
} else if (p_uri.contains("://")) {
141141
const String proto = p_uri.substr(0, p_uri.find("://") + 3);
142142
if (!protocols.has(proto)) {
143143
return;

core/extension/extension_api_dump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
12011201
if (F.name.begins_with("_")) {
12021202
continue; //hidden property
12031203
}
1204-
if (F.name.find("/") >= 0) {
1204+
if (F.name.contains("/")) {
12051205
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
12061206
continue;
12071207
}

core/io/ip_address.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ IPAddress::IPAddress(const String &p_string) {
202202
// Wildcard (not a valid IP)
203203
wildcard = true;
204204

205-
} else if (p_string.find(":") >= 0) {
205+
} else if (p_string.contains(":")) {
206206
// IPv6
207207
_parse_ipv6(p_string);
208208
valid = true;

core/string/ustring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3964,7 +3964,7 @@ String String::format(const Variant &values, const String &placeholder) const {
39643964
Variant v_val = values_arr[i];
39653965
String val = v_val;
39663966

3967-
if (placeholder.find("_") > -1) {
3967+
if (placeholder.contains("_")) {
39683968
new_string = new_string.replace(placeholder.replace("_", i_as_str), val);
39693969
} else {
39703970
new_string = new_string.replace_first(placeholder, val);

drivers/alsa/audio_driver_alsa.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Error AudioDriverALSA::init_output_device() {
5252
// If there is a specified output device check that it is really present
5353
if (output_device_name != "Default") {
5454
PackedStringArray list = get_output_device_list();
55-
if (list.find(output_device_name) == -1) {
55+
if (!list.has(output_device_name)) {
5656
output_device_name = "Default";
5757
new_output_device = "Default";
5858
}

drivers/egl/egl_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ Error EGLManager::initialize() {
383383
ERR_FAIL_COND_V(eglGetError() != EGL_SUCCESS, ERR_BUG);
384384

385385
const char *platform = _get_platform_extension_name();
386-
if (extensions_string.split(" ").find(platform) < 0) {
386+
if (!extensions_string.split(" ").has(platform)) {
387387
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, vformat("EGL platform extension \"%s\" not found.", platform));
388388
}
389389

drivers/pulseaudio/audio_driver_pulseaudio.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Error AudioDriverPulseAudio::init_output_device() {
183183
// If there is a specified output device, check that it is really present
184184
if (output_device_name != "Default") {
185185
PackedStringArray list = get_output_device_list();
186-
if (list.find(output_device_name) == -1) {
186+
if (!list.has(output_device_name)) {
187187
output_device_name = "Default";
188188
new_output_device = "Default";
189189
}
@@ -695,7 +695,7 @@ Error AudioDriverPulseAudio::init_input_device() {
695695
// If there is a specified input device, check that it is really present
696696
if (input_device_name != "Default") {
697697
PackedStringArray list = get_input_device_list();
698-
if (list.find(input_device_name) == -1) {
698+
if (!list.has(input_device_name)) {
699699
input_device_name = "Default";
700700
new_input_device = "Default";
701701
}

editor/create_dialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ float CreateDialog::_score_type(const String &p_type, const String &p_search) co
376376
score *= _is_type_preferred(p_type) ? 1.0f : 0.9f;
377377

378378
// Add score for being a favorite type.
379-
score *= (favorite_list.find(p_type) > -1) ? 1.0f : 0.8f;
379+
score *= favorite_list.has(p_type) ? 1.0f : 0.8f;
380380

381381
// Look through at most 5 recent items
382382
bool in_recent = false;

editor/debugger/debug_adapter/debug_adapter_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Dictionary DebugAdapterParser::req_setBreakpoints(const Dictionary &p_params) co
358358
}
359359

360360
// If path contains \, it's a Windows path, so we need to convert it to /, and make the drive letter uppercase
361-
if (source.path.find("\\") != -1) {
361+
if (source.path.contains("\\")) {
362362
source.path = source.path.replace("\\", "/");
363363
source.path = source.path.substr(0, 1).to_upper() + source.path.substr(1);
364364
}

editor/debugger/editor_debugger_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void EditorDebuggerNode::set_keep_open(bool p_keep_open) {
262262
}
263263

264264
Error EditorDebuggerNode::start(const String &p_uri) {
265-
ERR_FAIL_COND_V(p_uri.find("://") < 0, ERR_INVALID_PARAMETER);
265+
ERR_FAIL_COND_V(!p_uri.contains("://"), ERR_INVALID_PARAMETER);
266266
if (keep_open && current_uri == p_uri && server.is_valid()) {
267267
return OK;
268268
}

0 commit comments

Comments
 (0)