summaryrefslogtreecommitdiff
path: root/core/string
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2021-07-24 15:46:25 +0200
committerRémi Verschelde <rverschelde@gmail.com>2021-07-25 12:22:25 +0200
commitac3322b0af8f23e8e2dac8111200bc69b5604c9f (patch)
tree59a079f13b5c03c2dd3328a26c55f3618e6014f6 /core/string
parenta0f7f42b842462646281f5c4c9a8db070e034adc (diff)
Use const references where possible for List range iterators
Diffstat (limited to 'core/string')
-rw-r--r--core/string/optimized_translation.cpp2
-rw-r--r--core/string/translation.cpp2
-rw-r--r--core/string/translation_po.cpp12
-rw-r--r--core/string/ustring.cpp2
4 files changed, 9 insertions, 9 deletions
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<Translation> &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<String> Translation::_get_message_list() const {
void Translation::_set_messages(const Dictionary &p_messages) {
List<Variant> 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<StringName> 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<StringName, Vector<StringName>> &inner_map = translation_map[ctx];
@@ -73,7 +73,7 @@ Dictionary TranslationPO::_get_messages() const {
List<StringName> context_l;
translation_map.get_key_list(&context_l);
- for (StringName &ctx : context_l) {
+ for (const StringName &ctx : context_l) {
const HashMap<StringName, Vector<StringName>> &id_str_map = translation_map[ctx];
Dictionary d2;
@@ -96,7 +96,7 @@ void TranslationPO::_set_messages(const Dictionary &p_messages) {
List<Variant> 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<StringName, Vector<StringName>> temp_map;
@@ -118,7 +118,7 @@ Vector<String> TranslationPO::_get_message_list() const {
get_message_list(&msgs);
Vector<String> v;
- for (StringName &E : msgs) {
+ for (const StringName &E : msgs) {
v.push_back(E);
}
@@ -278,7 +278,7 @@ void TranslationPO::get_message_list(List<StringName> *r_messages) const {
List<StringName> 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<Variant> 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 {