You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Use const references where possible for List range iterators
This commit is contained in:
@@ -50,7 +50,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n
|
||||
List<Connection> all_connections;
|
||||
p_nodes[i]->get_signals_connected_to_this(&all_connections);
|
||||
|
||||
for (Connection &connection : all_connections) {
|
||||
for (const Connection &connection : all_connections) {
|
||||
if (connection.callable.get_method() != p_method) {
|
||||
continue;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ Vector<String> ScriptTextEditor::get_functions() {
|
||||
if (script->get_language()->validate(text, script->get_path(), &fnc)) {
|
||||
//if valid rewrite functions to latest
|
||||
functions.clear();
|
||||
for (String &E : fnc) {
|
||||
for (const String &E : fnc) {
|
||||
functions.push_back(E);
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() {
|
||||
List<String> strings;
|
||||
script->get_language()->get_string_delimiters(&strings);
|
||||
text_edit->clear_string_delimiters();
|
||||
for (String &string : strings) {
|
||||
for (const String &string : strings) {
|
||||
String beg = string.get_slice(" ", 0);
|
||||
String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
|
||||
text_edit->add_string_delimiter(beg, end, end == "");
|
||||
@@ -210,7 +210,7 @@ void ScriptTextEditor::_set_theme_for_script() {
|
||||
List<String> comments;
|
||||
script->get_language()->get_comment_delimiters(&comments);
|
||||
text_edit->clear_comment_delimiters();
|
||||
for (String &comment : comments) {
|
||||
for (const String &comment : comments) {
|
||||
String beg = comment.get_slice(" ", 0);
|
||||
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
|
||||
text_edit->add_comment_delimiter(beg, end, end == "");
|
||||
@@ -413,7 +413,7 @@ void ScriptTextEditor::_validate_script() {
|
||||
}
|
||||
|
||||
functions.clear();
|
||||
for (String &E : fnc) {
|
||||
for (const String &E : fnc) {
|
||||
functions.push_back(E);
|
||||
}
|
||||
script_is_valid = true;
|
||||
@@ -428,7 +428,7 @@ void ScriptTextEditor::_validate_script() {
|
||||
Node *base = get_tree()->get_edited_scene_root();
|
||||
if (base && missing_connections.size() > 0) {
|
||||
warnings_panel->push_table(1);
|
||||
for (Connection &connection : missing_connections) {
|
||||
for (const Connection &connection : missing_connections) {
|
||||
String base_path = base->get_name();
|
||||
String source_path = base == connection.signal.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.signal.get_object()));
|
||||
String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.callable.get_object()));
|
||||
@@ -450,7 +450,7 @@ void ScriptTextEditor::_validate_script() {
|
||||
|
||||
// Add script warnings.
|
||||
warnings_panel->push_table(3);
|
||||
for (ScriptLanguage::Warning &w : warnings) {
|
||||
for (const ScriptLanguage::Warning &w : warnings) {
|
||||
Dictionary ignore_meta;
|
||||
ignore_meta["line"] = w.start_line;
|
||||
ignore_meta["code"] = w.string_code.to_lower();
|
||||
@@ -480,7 +480,7 @@ void ScriptTextEditor::_validate_script() {
|
||||
|
||||
errors_panel->clear();
|
||||
errors_panel->push_table(2);
|
||||
for (ScriptLanguage::ScriptError &err : errors) {
|
||||
for (const ScriptLanguage::ScriptError &err : errors) {
|
||||
errors_panel->push_cell();
|
||||
errors_panel->push_meta(err.line - 1);
|
||||
errors_panel->push_color(warnings_panel->get_theme_color(SNAME("error_color"), SNAME("Editor")));
|
||||
@@ -501,7 +501,7 @@ void ScriptTextEditor::_validate_script() {
|
||||
if (errors.is_empty()) {
|
||||
te->set_line_background_color(i, Color(0, 0, 0, 0));
|
||||
} else {
|
||||
for (ScriptLanguage::ScriptError &E : errors) {
|
||||
for (const ScriptLanguage::ScriptError &E : errors) {
|
||||
bool error_line = i == E.line - 1;
|
||||
te->set_line_background_color(i, error_line ? marked_line_color : Color(0, 0, 0, 0));
|
||||
if (error_line) {
|
||||
@@ -900,7 +900,7 @@ void ScriptTextEditor::_update_connected_methods() {
|
||||
List<Connection> connections;
|
||||
nodes[i]->get_signals_connected_to_this(&connections);
|
||||
|
||||
for (Connection &connection : connections) {
|
||||
for (const Connection &connection : connections) {
|
||||
if (!(connection.flags & CONNECT_PERSIST)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1275,7 +1275,7 @@ void ScriptTextEditor::_edit_option_toggle_inline_comment() {
|
||||
List<String> comment_delimiters;
|
||||
script->get_language()->get_comment_delimiters(&comment_delimiters);
|
||||
|
||||
for (String &script_delimiter : comment_delimiters) {
|
||||
for (const String &script_delimiter : comment_delimiters) {
|
||||
if (script_delimiter.find(" ") == -1) {
|
||||
delimiter = script_delimiter;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user