summaryrefslogtreecommitdiff
path: root/core/variant
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/variant
parenta0f7f42b842462646281f5c4c9a8db070e034adc (diff)
Use const references where possible for List range iterators
Diffstat (limited to 'core/variant')
-rw-r--r--core/variant/callable.cpp2
-rw-r--r--core/variant/variant.cpp2
-rw-r--r--core/variant/variant_call.cpp4
-rw-r--r--core/variant/variant_parser.cpp2
-rw-r--r--core/variant/variant_setget.cpp4
-rw-r--r--core/variant/variant_utility.cpp2
6 files changed, 8 insertions, 8 deletions
diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp
index 2a3a9a4f1a..f487e718f4 100644
--- a/core/variant/callable.cpp
+++ b/core/variant/callable.cpp
@@ -407,7 +407,7 @@ Array Signal::get_connections() const {
object->get_signal_connection_list(name, &connections);
Array arr;
- for (Object::Connection &E : connections) {
+ for (const Object::Connection &E : connections) {
arr.push_back(E);
}
return arr;
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 12b6465005..97a1b4c02a 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -1681,7 +1681,7 @@ String Variant::stringify(List<const void *> &stack) const {
Vector<_VariantStrPair> pairs;
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
_VariantStrPair sp;
sp.key = E.stringify(stack);
sp.value = d[E].stringify(stack);
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index a9645da045..f8538f71d3 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1124,7 +1124,7 @@ bool Variant::has_builtin_method_return_value(Variant::Type p_type, const String
void Variant::get_builtin_method_list(Variant::Type p_type, List<StringName> *p_list) {
ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
- for (StringName &E : builtin_method_names[p_type]) {
+ for (const StringName &E : builtin_method_names[p_type]) {
p_list->push_back(E);
}
}
@@ -1188,7 +1188,7 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const {
obj->get_method_list(p_list);
}
} else {
- for (StringName &E : builtin_method_names[type]) {
+ for (const StringName &E : builtin_method_names[type]) {
const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E);
ERR_CONTINUE(!method);
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp
index dc92ac8ac4..50c48fd386 100644
--- a/core/variant/variant_parser.cpp
+++ b/core/variant/variant_parser.cpp
@@ -1586,7 +1586,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
List<PropertyInfo> props;
obj->get_property_list(&props);
bool first = true;
- for (PropertyInfo &E : props) {
+ for (const PropertyInfo &E : props) {
if (E.usage & PROPERTY_USAGE_STORAGE || E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) {
//must be serialized
diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp
index 62228ea87c..ae3c7685fd 100644
--- a/core/variant/variant_setget.cpp
+++ b/core/variant/variant_setget.cpp
@@ -1093,7 +1093,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
List<Variant> keys;
dic->get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
if (E.get_type() == Variant::STRING) {
p_list->push_back(PropertyInfo(Variant::STRING, E));
}
@@ -1106,7 +1106,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
} else {
List<StringName> members;
get_member_list(type, &members);
- for (StringName &E : members) {
+ for (const StringName &E : members) {
PropertyInfo pi;
pi.name = E;
pi.type = get_member_type(type, E);
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index e9fa952af3..64f07e075e 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -1397,7 +1397,7 @@ uint32_t Variant::get_utility_function_hash(const StringName &p_name) {
}
void Variant::get_utility_function_list(List<StringName> *r_functions) {
- for (StringName &E : utility_function_name_table) {
+ for (const StringName &E : utility_function_name_table) {
r_functions->push_back(E);
}
}