Skip to content

Commit 1237536

Browse files
committed
Merge pull request godotengine#102630 from KoBeWi/what_the_loop
Improve `_is_drop_valid()` code in EditorPropertyArray
2 parents 47761b1 + b9a6057 commit 1237536

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

editor/editor_properties_array_dict.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,10 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
569569
if (drop_type == "files") {
570570
PackedStringArray files = drag_data["files"];
571571

572-
for (int i = 0; i < files.size(); i++) {
573-
const String &file = files[i];
574-
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
575-
576-
for (int j = 0; j < allowed_type.get_slice_count(","); j++) {
577-
String at = allowed_type.get_slice(",", j).strip_edges();
572+
for (const String &file : files) {
573+
const String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
574+
for (String at : allowed_type.split(",")) {
575+
at = at.strip_edges();
578576
// Fail if one of the files is not of allowed type.
579577
if (!ClassDB::is_parent_class(ftype, at)) {
580578
return false;
@@ -594,8 +592,8 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
594592
if (subtype_hint_string == "NodePath") {
595593
return true;
596594
} else {
597-
for (int j = 0; j < subtype_hint_string.get_slice_count(","); j++) {
598-
String ast = subtype_hint_string.get_slice(",", j).strip_edges();
595+
for (String ast : subtype_hint_string.split(",")) {
596+
ast = ast.strip_edges();
599597
allowed_subtype_array.append(ast);
600598
}
601599
}
@@ -644,8 +642,6 @@ bool EditorPropertyArray::can_drop_data_fw(const Point2 &p_point, const Variant
644642
}
645643

646644
void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
647-
ERR_FAIL_COND(!_is_drop_valid(p_data));
648-
649645
Dictionary drag_data = p_data;
650646
const String drop_type = drag_data.get("type", "");
651647
Variant array = object->get_array();

0 commit comments

Comments
 (0)