Skip to content

Commit cae3d72

Browse files
committed
Merge pull request #99321 from AThousandShips/use_get_slicec
Use `get_slicec` instead of `get_slice` for single character splitters
2 parents 3a0b8da + 466590d commit cae3d72

File tree

58 files changed

+210
-210
lines changed

Some content is hidden

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

58 files changed

+210
-210
lines changed

core/config/project_settings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
289289
remove_autoload(node_name);
290290
}
291291
} else if (p_name.operator String().begins_with("global_group/")) {
292-
String group_name = p_name.operator String().get_slice("/", 1);
292+
String group_name = p_name.operator String().get_slicec('/', 1);
293293
if (global_groups.has(group_name)) {
294294
remove_global_group(group_name);
295295
}
@@ -340,7 +340,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
340340
}
341341
add_autoload(autoload);
342342
} else if (p_name.operator String().begins_with("global_group/")) {
343-
String group_name = p_name.operator String().get_slice("/", 1);
343+
String group_name = p_name.operator String().get_slicec('/', 1);
344344
add_global_group(group_name, p_value);
345345
}
346346
}

core/input/input.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,8 @@ void Input::parse_mapping(const String &p_mapping) {
15941594
continue;
15951595
}
15961596

1597-
String output = entry[idx].get_slice(":", 0).replace(" ", "");
1598-
String input = entry[idx].get_slice(":", 1).replace(" ", "");
1597+
String output = entry[idx].get_slicec(':', 0).replace(" ", "");
1598+
String input = entry[idx].get_slicec(':', 1).replace(" ", "");
15991599
if (output.length() < 1 || input.length() < 2) {
16001600
continue;
16011601
}

core/string/translation_server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ TranslationServer::Locale::Locale(const TranslationServer &p_server, const Strin
138138
String univ_locale = p_locale.replace("-", "_");
139139

140140
// Extract locale elements.
141-
Vector<String> locale_elements = univ_locale.get_slice("@", 0).split("_");
141+
Vector<String> locale_elements = univ_locale.get_slicec('@', 0).split("_");
142142
language = locale_elements[0];
143143
if (locale_elements.size() >= 2) {
144144
if (locale_elements[1].length() == 4 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_lower_case(locale_elements[1][1]) && is_ascii_lower_case(locale_elements[1][2]) && is_ascii_lower_case(locale_elements[1][3])) {
@@ -162,7 +162,7 @@ TranslationServer::Locale::Locale(const TranslationServer &p_server, const Strin
162162
}
163163

164164
// Try extract script and variant from the extra part.
165-
Vector<String> script_extra = univ_locale.get_slice("@", 1).split(";");
165+
Vector<String> script_extra = univ_locale.get_slicec('@', 1).split(";");
166166
for (int i = 0; i < script_extra.size(); i++) {
167167
if (script_extra[i].to_lower() == "cyrillic") {
168168
script = "Cyrl";

drivers/gles3/storage/config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Config::Config() {
226226
// OpenGL ES 3.0 [email protected] (GIT@35e467f, Ice9844a736) (Date:04/15/19)
227227
// OpenGL ES 3.0 [email protected] (GIT@d39f783, I79de86aa2c, 1591296226) (Date:06/04/20)
228228
// OpenGL ES 3.0 [email protected] (GIT@09fef447e8, I1fe547a144, 1661493934) (Date:08/25/22)
229-
String driver_version = gl_version.get_slice("V@", 1).get_slice(" ", 0);
229+
String driver_version = gl_version.get_slice("V@", 1).get_slicec(' ', 0);
230230
if (driver_version.is_valid_float() && driver_version.to_float() >= 331.0) {
231231
flip_xy_workaround = false;
232232

drivers/gles3/storage/material_storage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ void MaterialStorage::global_shader_parameters_load_settings(bool p_load_texture
19251925

19261926
for (const PropertyInfo &E : settings) {
19271927
if (E.name.begins_with("shader_globals/")) {
1928-
StringName name = E.name.get_slice("/", 1);
1928+
StringName name = E.name.get_slicec('/', 1);
19291929
Dictionary d = GLOBAL_GET(E.name);
19301930

19311931
ERR_CONTINUE(!d.has("type"));

editor/animation_track_editor.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ bool AnimationTrackKeyEdit::_set(const StringName &p_name, const Variant &p_valu
221221
change_notify_deserved = true;
222222
} else if (name.begins_with("args/")) {
223223
Vector<Variant> args = d_old["args"];
224-
int idx = name.get_slice("/", 1).to_int();
224+
int idx = name.get_slicec('/', 1).to_int();
225225
ERR_FAIL_INDEX_V(idx, args.size(), false);
226226

227-
String what = name.get_slice("/", 2);
227+
String what = name.get_slicec('/', 2);
228228
if (what == "type") {
229229
Variant::Type t = Variant::Type(int(p_value));
230230

@@ -478,10 +478,10 @@ bool AnimationTrackKeyEdit::_get(const StringName &p_name, Variant &r_ret) const
478478
}
479479

480480
if (name.begins_with("args/")) {
481-
int idx = name.get_slice("/", 1).to_int();
481+
int idx = name.get_slicec('/', 1).to_int();
482482
ERR_FAIL_INDEX_V(idx, args.size(), false);
483483

484-
String what = name.get_slice("/", 2);
484+
String what = name.get_slicec('/', 2);
485485
if (what == "type") {
486486
r_ret = args[idx].get_type();
487487
return true;
@@ -833,10 +833,10 @@ bool AnimationMultiTrackKeyEdit::_set(const StringName &p_name, const Variant &p
833833
change_notify_deserved = true;
834834
} else if (name.begins_with("args/")) {
835835
Vector<Variant> args = d_old["args"];
836-
int idx = name.get_slice("/", 1).to_int();
836+
int idx = name.get_slicec('/', 1).to_int();
837837
ERR_FAIL_INDEX_V(idx, args.size(), false);
838838

839-
String what = name.get_slice("/", 2);
839+
String what = name.get_slicec('/', 2);
840840
if (what == "type") {
841841
Variant::Type t = Variant::Type(int(p_value));
842842

@@ -1055,10 +1055,10 @@ bool AnimationMultiTrackKeyEdit::_get(const StringName &p_name, Variant &r_ret)
10551055
}
10561056

10571057
if (name.begins_with("args/")) {
1058-
int idx = name.get_slice("/", 1).to_int();
1058+
int idx = name.get_slicec('/', 1).to_int();
10591059
ERR_FAIL_INDEX_V(idx, args.size(), false);
10601060

1061-
String what = name.get_slice("/", 2);
1061+
String what = name.get_slicec('/', 2);
10621062
if (what == "type") {
10631063
r_ret = args[idx].get_type();
10641064
return true;
@@ -3324,7 +3324,7 @@ Variant AnimationTrackEdit::get_drag_data(const Point2 &p_point) {
33243324
Dictionary drag_data;
33253325
drag_data["type"] = "animation_track";
33263326
String base_path = animation->track_get_path(track);
3327-
base_path = base_path.get_slice(":", 0); // Remove sub-path.
3327+
base_path = base_path.get_slicec(':', 0); // Remove sub-path.
33283328
drag_data["group"] = base_path;
33293329
drag_data["index"] = track;
33303330

@@ -3355,7 +3355,7 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d
33553355
// Don't allow moving tracks outside their groups.
33563356
if (get_editor()->is_grouping_tracks()) {
33573357
String base_path = animation->track_get_path(track);
3358-
base_path = base_path.get_slice(":", 0); // Remove sub-path.
3358+
base_path = base_path.get_slicec(':', 0); // Remove sub-path.
33593359
if (d["group"] != base_path) {
33603360
return false;
33613361
}
@@ -3386,7 +3386,7 @@ void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data)
33863386
// Don't allow moving tracks outside their groups.
33873387
if (get_editor()->is_grouping_tracks()) {
33883388
String base_path = animation->track_get_path(track);
3389-
base_path = base_path.get_slice(":", 0); // Remove sub-path.
3389+
base_path = base_path.get_slicec(':', 0); // Remove sub-path.
33903390
if (d["group"] != base_path) {
33913391
return;
33923392
}
@@ -4935,7 +4935,7 @@ void AnimationTrackEditor::_update_tracks() {
49354935

49364936
if (use_grouping) {
49374937
String base_path = animation->track_get_path(i);
4938-
base_path = base_path.get_slice(":", 0); // Remove sub-path.
4938+
base_path = base_path.get_slicec(':', 0); // Remove sub-path.
49394939

49404940
if (!group_sort.has(base_path)) {
49414941
AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup);

editor/connections_dialog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ConnectDialogBinds : public Object {
8181
String name = p_name;
8282

8383
if (name.begins_with("bind/argument_")) {
84-
int which = name.get_slice("_", 1).to_int() - 1;
84+
int which = name.get_slicec('_', 1).to_int() - 1;
8585
ERR_FAIL_INDEX_V(which, params.size(), false);
8686
params.write[which] = p_value;
8787
} else {
@@ -95,7 +95,7 @@ class ConnectDialogBinds : public Object {
9595
String name = p_name;
9696

9797
if (name.begins_with("bind/argument_")) {
98-
int which = name.get_slice("_", 1).to_int() - 1;
98+
int which = name.get_slicec('_', 1).to_int() - 1;
9999
ERR_FAIL_INDEX_V(which, params.size(), false);
100100
r_ret = params[which];
101101
} else {
@@ -224,7 +224,7 @@ void ConnectDialog::_remove_bind() {
224224
if (st.is_empty()) {
225225
return;
226226
}
227-
int idx = st.get_slice("/", 1).to_int() - 1;
227+
int idx = st.get_slicec('/', 1).to_int() - 1;
228228

229229
ERR_FAIL_INDEX(idx, cdbinds->params.size());
230230
cdbinds->params.remove_at(idx);
@@ -575,8 +575,8 @@ String ConnectDialog::get_signature(const MethodInfo &p_method, PackedStringArra
575575
case Variant::DICTIONARY:
576576
type_name = "Dictionary";
577577
if (pi.hint == PROPERTY_HINT_DICTIONARY_TYPE && !pi.hint_string.is_empty()) {
578-
String key_hint = pi.hint_string.get_slice(";", 0);
579-
String value_hint = pi.hint_string.get_slice(";", 1);
578+
String key_hint = pi.hint_string.get_slicec(';', 0);
579+
String value_hint = pi.hint_string.get_slicec(';', 1);
580580
if (key_hint.is_empty() || key_hint.begins_with("res://")) {
581581
key_hint = "Variant";
582582
}

editor/debugger/editor_debugger_inspector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void EditorDebuggerInspector::clear_stack_variables() {
290290
String EditorDebuggerInspector::get_stack_variable(const String &p_var) {
291291
for (KeyValue<StringName, Variant> &E : variables->prop_values) {
292292
String v = E.key.operator String();
293-
if (v.get_slice("/", 1) == p_var) {
293+
if (v.get_slicec('/', 1) == p_var) {
294294
return variables->get_variant(v);
295295
}
296296
}

editor/debugger/editor_file_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void EditorFileServer::_scan_files_changed(EditorFileSystemDirectory *efd, const
7878
uint64_t mt = FileAccess::get_modified_time(remapped_path);
7979
_add_file(remapped_path, mt, files_to_send, cached_files);
8080
} else if (remap.begins_with("path.")) {
81-
String feature = remap.get_slice(".", 1);
81+
String feature = remap.get_slicec('.', 1);
8282
if (p_tags.has(feature)) {
8383
String remapped_path = cf->get_value("remap", remap);
8484
uint64_t mt = FileAccess::get_modified_time(remapped_path);

editor/editor_about.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
133133

134134
while (*names_ptr) {
135135
const String name = String::utf8(*names_ptr++);
136-
const String identifier = name.get_slice("<", 0);
137-
const String website = name.get_slice_count("<") == 1 ? "" : name.get_slice("<", 1).trim_suffix(">");
136+
const String identifier = name.get_slicec('<', 0);
137+
const String website = name.get_slice_count("<") == 1 ? "" : name.get_slicec('<', 1).trim_suffix(">");
138138

139139
const int name_item_id = il->add_item(identifier, nullptr, false);
140140
il->set_item_tooltip_enabled(name_item_id, false);

0 commit comments

Comments
 (0)