Skip to content

Commit 23cc324

Browse files
RaftatulAThousandShipsKoBeWi
committed
Apply suggestions from code review
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
1 parent 79b3fa4 commit 23cc324

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

editor/inspector/editor_inspector.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,11 +1758,11 @@ Size2 EditorInspectorCategory::get_minimum_size() const {
17581758
return ms;
17591759
}
17601760

1761-
void EditorInspectorCategory::_collect_properties(const Object *p_object, Vector<String> &p_properties) const {
1761+
void EditorInspectorCategory::_collect_properties(const Object *p_object, LocalVector<String> &r_properties) const {
17621762
List<PropertyInfo> property_list;
17631763
p_object->get_property_list(&property_list, true);
17641764

1765-
String current_category = "";
1765+
String current_category;
17661766
for (const PropertyInfo &prop_info : property_list) {
17671767
if (prop_info.usage & PROPERTY_USAGE_GROUP) {
17681768
continue;
@@ -1778,7 +1778,7 @@ void EditorInspectorCategory::_collect_properties(const Object *p_object, Vector
17781778
continue;
17791779
}
17801780

1781-
p_properties.push_back(prop_info.name);
1781+
r_properties.push_back(prop_info.name);
17821782
}
17831783
}
17841784

@@ -1787,11 +1787,11 @@ void EditorInspectorCategory::_handle_menu_option(int p_option) {
17871787
case MENU_COPY_VALUE: {
17881788
Object *object = EditorInterface::get_singleton()->get_inspector()->get_edited_object();
17891789
Dictionary clipboard;
1790-
Vector<String> properties;
1790+
LocalVector<String> properties;
17911791
_collect_properties(object, properties);
17921792

17931793
clipboard["path"] = doc_class_name;
1794-
for (String property_name : properties) {
1794+
for (const String &property_name : properties) {
17951795
clipboard[property_name] = object->get(property_name);
17961796
}
17971797
InspectorDock::get_inspector_singleton()->set_property_clipboard(clipboard);
@@ -1806,14 +1806,14 @@ void EditorInspectorCategory::_handle_menu_option(int p_option) {
18061806
break;
18071807
}
18081808

1809-
String action_name = "Set category " + category_name;
1809+
String action_name = vformat(TTR("Set category %s"), category_name);
18101810

18111811
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
18121812
undo_redo->create_action(action_name);
18131813

1814-
for (String property_name : clipboard.keys()) {
1815-
Variant value = clipboard[property_name];
1816-
undo_redo->add_do_property(object, property_name, value);
1814+
for (const KeyValue<Variant, Variant> &pair : clipboard) {
1815+
String property_name = pair.key;
1816+
undo_redo->add_do_property(object, property_name, pair.value);
18171817
undo_redo->add_undo_property(object, property_name, object->get(property_name));
18181818
}
18191819

@@ -2533,13 +2533,13 @@ void EditorInspectorSection::_update_popup() {
25332533
menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionPaste")), ED_GET_SHORTCUT("property_editor/paste_group_values"), MENU_PASTE_VALUE);
25342534
}
25352535

2536-
void EditorInspectorSection::_collect_properties(Vector<String> &p_properties) const {
2536+
void EditorInspectorSection::_collect_properties(LocalVector<String> &r_properties) const {
25372537
List<PropertyInfo> property_list;
25382538
object->get_property_list(&property_list, true);
25392539

2540-
String current_category = "";
2541-
String current_group = "";
2542-
String current_subgroup = "";
2540+
String current_category;
2541+
String current_group;
2542+
String current_subgroup;
25432543
for (const PropertyInfo &prop_info : property_list) {
25442544
if (prop_info.usage & PROPERTY_USAGE_GROUP) {
25452545
current_group = prop_info.name;
@@ -2558,13 +2558,13 @@ void EditorInspectorSection::_collect_properties(Vector<String> &p_properties) c
25582558
if (!(prop_info.usage & PROPERTY_USAGE_EDITOR)) {
25592559
continue;
25602560
}
2561-
if (prop_info.name.split("/").size() > 1) {
2562-
current_group = prop_info.name.split("/")[0];
2561+
if (prop_info.name.get_slice_count("/") > 1) {
2562+
current_group = prop_info.name.get_slicec('/', 0);
25632563
}
25642564
if (!(current_category + "/" + current_group + "/" + current_subgroup).begins_with(get_inspector_path())) {
25652565
if (current_category.ends_with(".gd")) {
25662566
String section_path = inspector_path;
2567-
section_path = section_path.replace(section_path.split("/")[0] + "/", "");
2567+
section_path = section_path.replace(section_path.get_slicec('/', 0) + "/", "");
25682568
if (!(current_group + "/" + current_subgroup).begins_with(section_path)) {
25692569
continue;
25702570
}
@@ -2573,19 +2573,19 @@ void EditorInspectorSection::_collect_properties(Vector<String> &p_properties) c
25732573
}
25742574
}
25752575

2576-
p_properties.push_back(prop_info.name);
2576+
r_properties.push_back(prop_info.name);
25772577
}
25782578
}
25792579

25802580
void EditorInspectorSection::menu_option(int p_option) const {
25812581
switch (p_option) {
25822582
case MENU_COPY_VALUE: {
2583-
Vector<String> properties;
2583+
LocalVector<String> properties;
25842584
Dictionary clipboard;
25852585
_collect_properties(properties);
25862586

25872587
clipboard["path"] = get_inspector_path();
2588-
for (String property_name : properties) {
2588+
for (const String &property_name : properties) {
25892589
clipboard[property_name] = object->get(property_name);
25902590
}
25912591
InspectorDock::get_inspector_singleton()->set_property_clipboard(clipboard);
@@ -2598,15 +2598,15 @@ void EditorInspectorSection::menu_option(int p_option) const {
25982598
break;
25992599
}
26002600

2601-
Vector<String> properties;
2601+
LocalVector<String> properties;
26022602
String action_name = "Set group " + group_name;
26032603

26042604
_collect_properties(properties);
26052605

26062606
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
26072607
undo_redo->create_action(action_name);
26082608

2609-
for (String property_name : properties) {
2609+
for (const String &property_name : properties) {
26102610
Variant value = clipboard[property_name];
26112611
undo_redo->add_do_property(object, property_name, value);
26122612
undo_redo->add_undo_property(object, property_name, object->get(property_name));

editor/inspector/editor_inspector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class EditorInspectorCategory : public Control {
352352
bool is_favorite = false;
353353
bool menu_icon_dirty = true;
354354

355-
void _collect_properties(const Object *p_object, Vector<String> &p_properties) const;
355+
void _collect_properties(const Object *p_object, LocalVector<String> &r_properties) const;
356356
void _handle_menu_option(int p_option);
357357
void _popup_context_menu(const Point2i &p_position);
358358
void _update_icon();
@@ -489,7 +489,7 @@ class EditorInspectorSection : public Container {
489489
void update_property();
490490

491491
void _update_popup();
492-
void _collect_properties(Vector<String> &p_properties) const;
492+
void _collect_properties(LocalVector<String> &r_properties) const;
493493
void menu_option(int p_option) const;
494494

495495
EditorInspectorSection();

0 commit comments

Comments
 (0)