From ac3322b0af8f23e8e2dac8111200bc69b5604c9f Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Sat, 24 Jul 2021 15:46:25 +0200 Subject: Use const references where possible for List range iterators --- core/string/optimized_translation.cpp | 2 +- core/string/translation.cpp | 2 +- core/string/translation_po.cpp | 12 ++++++------ core/string/ustring.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'core/string') diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp index cf0b8d10db..5863bd1c46 100644 --- a/core/string/optimized_translation.cpp +++ b/core/string/optimized_translation.cpp @@ -66,7 +66,7 @@ void OptimizedTranslation::generate(const Ref &p_from) { int total_compression_size = 0; int total_string_size = 0; - for (StringName &E : keys) { + for (const StringName &E : keys) { //hash string CharString cs = E.operator String().utf8(); uint32_t h = hash(0, cs.get_data()); diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 981954c8ae..19d23fd375 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -841,7 +841,7 @@ Vector Translation::_get_message_list() const { void Translation::_set_messages(const Dictionary &p_messages) { List keys; p_messages.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { translation_map[E] = p_messages[E]; } } diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index afd3b76588..1da00aa54b 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -47,7 +47,7 @@ void TranslationPO::print_translation_map() { List context_l; translation_map.get_key_list(&context_l); - for (StringName &ctx : context_l) { + for (const StringName &ctx : context_l) { file->store_line(" ===== Context: " + String::utf8(String(ctx).utf8()) + " ===== "); const HashMap> &inner_map = translation_map[ctx]; @@ -73,7 +73,7 @@ Dictionary TranslationPO::_get_messages() const { List context_l; translation_map.get_key_list(&context_l); - for (StringName &ctx : context_l) { + for (const StringName &ctx : context_l) { const HashMap> &id_str_map = translation_map[ctx]; Dictionary d2; @@ -96,7 +96,7 @@ void TranslationPO::_set_messages(const Dictionary &p_messages) { List context_l; p_messages.get_key_list(&context_l); - for (Variant &ctx : context_l) { + for (const Variant &ctx : context_l) { const Dictionary &id_str_map = p_messages[ctx]; HashMap> temp_map; @@ -118,7 +118,7 @@ Vector TranslationPO::_get_message_list() const { get_message_list(&msgs); Vector v; - for (StringName &E : msgs) { + for (const StringName &E : msgs) { v.push_back(E); } @@ -278,7 +278,7 @@ void TranslationPO::get_message_list(List *r_messages) const { List context_l; translation_map.get_key_list(&context_l); - for (StringName &E : context_l) { + for (const StringName &E : context_l) { if (String(E) != "") { continue; } @@ -297,7 +297,7 @@ int TranslationPO::get_message_count() const { translation_map.get_key_list(&context_l); int count = 0; - for (StringName &E : context_l) { + for (const StringName &E : context_l) { count += translation_map[E].size(); } return count; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index dbb8dc8283..7beecdb6b5 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3421,7 +3421,7 @@ String String::format(const Variant &values, String placeholder) const { List keys; d.get_key_list(&keys); - for (Variant &key : keys) { + for (const Variant &key : keys) { new_string = new_string.replace(placeholder.replace("_", key), d[key]); } } else { -- cgit v1.2.3