summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/config/engine.cpp2
-rw-r--r--core/config/project_settings.cpp4
-rw-r--r--core/core_bind.cpp20
-rw-r--r--core/debugger/debugger_marshalls.cpp2
-rw-r--r--core/debugger/remote_debugger.cpp2
-rw-r--r--core/extension/extension_api_dump.cpp24
-rw-r--r--core/extension/native_extension.cpp2
-rw-r--r--core/input/input.cpp2
-rw-r--r--core/input/input_map.cpp4
-rw-r--r--core/io/dir_access.cpp6
-rw-r--r--core/io/image_loader.cpp2
-rw-r--r--core/io/ip.cpp2
-rw-r--r--core/io/json.cpp2
-rw-r--r--core/io/marshalls.cpp6
-rw-r--r--core/io/multiplayer_api.cpp2
-rw-r--r--core/io/packed_data_container.cpp4
-rw-r--r--core/io/resource.cpp10
-rw-r--r--core/io/resource_format_binary.cpp21
-rw-r--r--core/io/resource_importer.cpp8
-rw-r--r--core/io/resource_loader.cpp6
-rw-r--r--core/io/resource_saver.cpp4
-rw-r--r--core/math/quick_hull.cpp4
-rw-r--r--core/object/class_db.cpp30
-rw-r--r--core/object/object.cpp14
-rw-r--r--core/object/script_language.cpp12
-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
-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
35 files changed, 115 insertions, 114 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp
index c03c872f17..0b5b5627af 100644
--- a/core/config/engine.cpp
+++ b/core/config/engine.cpp
@@ -214,7 +214,7 @@ bool Engine::has_singleton(const String &p_name) const {
}
void Engine::get_singletons(List<Singleton> *p_singletons) {
- for (Singleton &E : singletons) {
+ for (const Singleton &E : singletons) {
p_singletons->push_back(E);
}
}
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index 22acb23bce..c5e6c6d685 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -800,7 +800,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
if (E->key() != "") {
file->store_string("[" + E->key() + "]\n\n");
}
- for (String &F : E->get()) {
+ for (const String &F : E->get()) {
String key = F;
if (E->key() != "") {
key = E->key() + "/" + key;
@@ -928,7 +928,7 @@ Vector<String> ProjectSettings::get_optimizer_presets() const {
ProjectSettings::get_singleton()->get_property_list(&pi);
Vector<String> names;
- for (PropertyInfo &E : pi) {
+ for (const PropertyInfo &E : pi) {
if (!E.name.begins_with("optimizer_presets/")) {
continue;
}
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 7a1ba63233..12fca4215a 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -75,7 +75,7 @@ Vector<String> _ResourceLoader::get_recognized_extensions_for_type(const String
List<String> exts;
ResourceLoader::get_recognized_extensions_for_type(p_type, &exts);
Vector<String> ret;
- for (String &E : exts) {
+ for (const String &E : exts) {
ret.push_back(E);
}
@@ -91,7 +91,7 @@ PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) {
ResourceLoader::get_dependencies(p_path, &deps);
PackedStringArray ret;
- for (String &E : deps) {
+ for (const String &E : deps) {
ret.push_back(E);
}
@@ -141,7 +141,7 @@ Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource)
List<String> exts;
ResourceSaver::get_recognized_extensions(p_resource, &exts);
Vector<String> ret;
- for (String &E : exts) {
+ for (const String &E : exts) {
ret.push_back(E);
}
return ret;
@@ -268,7 +268,7 @@ String _OS::get_name() const {
Vector<String> _OS::get_cmdline_args() {
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
Vector<String> cmdlinev;
- for (String &E : cmdline) {
+ for (const String &E : cmdline) {
cmdlinev.push_back(E);
}
@@ -1822,7 +1822,7 @@ PackedStringArray _ClassDB::get_class_list() const {
PackedStringArray ret;
ret.resize(classes.size());
int idx = 0;
- for (StringName &E : classes) {
+ for (const StringName &E : classes) {
ret.set(idx++, E);
}
@@ -1836,7 +1836,7 @@ PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class)
PackedStringArray ret;
ret.resize(classes.size());
int idx = 0;
- for (StringName &E : classes) {
+ for (const StringName &E : classes) {
ret.set(idx++, E);
}
@@ -1891,7 +1891,7 @@ Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const
ClassDB::get_signal_list(p_class, &signals, p_no_inheritance);
Array ret;
- for (MethodInfo &E : signals) {
+ for (const MethodInfo &E : signals) {
ret.push_back(E.operator Dictionary());
}
@@ -1902,7 +1902,7 @@ Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) con
List<PropertyInfo> plist;
ClassDB::get_property_list(p_class, &plist, p_no_inheritance);
Array ret;
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
ret.push_back(E.operator Dictionary());
}
@@ -1935,7 +1935,7 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const
ClassDB::get_method_list(p_class, &methods, p_no_inheritance);
Array ret;
- for (MethodInfo &E : methods) {
+ for (const MethodInfo &E : methods) {
#ifdef DEBUG_METHODS_ENABLED
ret.push_back(E.operator Dictionary());
#else
@@ -1955,7 +1955,7 @@ PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class,
PackedStringArray ret;
ret.resize(constants.size());
int idx = 0;
- for (String &E : constants) {
+ for (const String &E : constants) {
ret.set(idx++, E);
}
diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp
index b832dd58d5..2353a6ebf8 100644
--- a/core/debugger/debugger_marshalls.cpp
+++ b/core/debugger/debugger_marshalls.cpp
@@ -40,7 +40,7 @@ Array DebuggerMarshalls::ResourceUsage::serialize() {
Array arr;
arr.push_back(infos.size() * 4);
- for (ResourceInfo &E : infos) {
+ for (const ResourceInfo &E : infos) {
arr.push_back(E.path);
arr.push_back(E.format);
arr.push_back(E.type);
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp
index 7d3abc9b46..0add12ff3d 100644
--- a/core/debugger/remote_debugger.cpp
+++ b/core/debugger/remote_debugger.cpp
@@ -427,7 +427,7 @@ void RemoteDebugger::_send_resource_usage() {
List<RS::TextureInfo> tinfo;
RS::get_singleton()->texture_debug_usage(&tinfo);
- for (RS::TextureInfo &E : tinfo) {
+ for (const RS::TextureInfo &E : tinfo) {
DebuggerMarshalls::ResourceInfo info;
info.path = E.path;
info.vram = E.bytes;
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp
index cc2974cbdb..a3a91f1247 100644
--- a/core/extension/extension_api_dump.cpp
+++ b/core/extension/extension_api_dump.cpp
@@ -276,7 +276,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Dictionary d1;
d1["name"] = E->key();
Array values;
- for (Pair<String, int> &F : E->get()) {
+ for (const Pair<String, int> &F : E->get()) {
Dictionary d2;
d2["name"] = F.first;
d2["value"] = F.second;
@@ -294,7 +294,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<StringName> utility_func_names;
Variant::get_utility_function_list(&utility_func_names);
- for (StringName &name : utility_func_names) {
+ for (const StringName &name : utility_func_names) {
Dictionary func;
func["name"] = String(name);
if (Variant::has_utility_function_return_value(name)) {
@@ -362,7 +362,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<StringName> member_names;
Variant::get_member_list(type, &member_names);
- for (StringName &member_name : member_names) {
+ for (const StringName &member_name : member_names) {
Dictionary d2;
d2["name"] = String(member_name);
d2["type"] = Variant::get_type_name(Variant::get_member_type(type, member_name));
@@ -378,7 +378,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<StringName> constant_names;
Variant::get_constants_for_type(type, &constant_names);
- for (StringName &constant_name : constant_names) {
+ for (const StringName &constant_name : constant_names) {
Dictionary d2;
d2["name"] = String(constant_name);
Variant constant = Variant::get_constant_value(type, constant_name);
@@ -417,7 +417,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<StringName> method_names;
Variant::get_builtin_method_list(type, &method_names);
- for (StringName &method_name : method_names) {
+ for (const StringName &method_name : method_names) {
Dictionary d2;
d2["name"] = String(method_name);
if (Variant::has_builtin_method_return_value(type, method_name)) {
@@ -499,7 +499,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
class_list.sort_custom<StringName::AlphCompare>();
- for (StringName &class_name : class_list) {
+ for (const StringName &class_name : class_list) {
Dictionary d;
d["name"] = String(class_name);
d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted");
@@ -520,7 +520,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array constants;
List<String> constant_list;
ClassDB::get_integer_constant_list(class_name, &constant_list, true);
- for (String &F : constant_list) {
+ for (const String &F : constant_list) {
StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F);
if (enum_name != StringName()) {
continue; //enums will be handled on their own
@@ -542,7 +542,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array enums;
List<StringName> enum_list;
ClassDB::get_enum_list(class_name, &enum_list, true);
- for (StringName &F : enum_list) {
+ for (const StringName &F : enum_list) {
Dictionary d2;
d2["name"] = String(F);
@@ -570,7 +570,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array methods;
List<MethodInfo> method_list;
ClassDB::get_method_list(class_name, &method_list, true);
- for (MethodInfo &F : method_list) {
+ for (const MethodInfo &F : method_list) {
StringName method_name = F.name;
if (F.flags & METHOD_FLAG_VIRTUAL) {
//virtual method
@@ -687,7 +687,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array signals;
List<MethodInfo> signal_list;
ClassDB::get_signal_list(class_name, &signal_list, true);
- for (MethodInfo &F : signal_list) {
+ for (const MethodInfo &F : signal_list) {
StringName signal_name = F.name;
Dictionary d2;
d2["name"] = String(signal_name);
@@ -723,7 +723,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array properties;
List<PropertyInfo> property_list;
ClassDB::get_property_list(class_name, &property_list, true);
- for (PropertyInfo &F : property_list) {
+ for (const PropertyInfo &F : property_list) {
if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP) {
continue; //not real properties
}
@@ -766,7 +766,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<Engine::Singleton> singleton_list;
Engine::get_singleton()->get_singletons(&singleton_list);
- for (Engine::Singleton &s : singleton_list) {
+ for (const Engine::Singleton &s : singleton_list) {
Dictionary d;
d["name"] = s.name;
if (s.class_name != StringName()) {
diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp
index 5f91e61102..16bc28e0a2 100644
--- a/core/extension/native_extension.cpp
+++ b/core/extension/native_extension.cpp
@@ -351,7 +351,7 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or
String library_path;
- for (String &E : libraries) {
+ for (const String &E : libraries) {
Vector<String> tags = E.split(".");
bool all_tags_met = true;
for (int i = 0; i < tags.size(); i++) {
diff --git a/core/input/input.cpp b/core/input/input.cpp
index e30e7c814f..c205726b0a 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -174,7 +174,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
List<PropertyInfo> pinfo;
ProjectSettings::get_singleton()->get_property_list(&pinfo);
- for (PropertyInfo &pi : pinfo) {
+ for (const PropertyInfo &pi : pinfo) {
if (!pi.name.begins_with("input/")) {
continue;
}
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index 0c8705b263..6714705bb5 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -65,7 +65,7 @@ String InputMap::_suggest_actions(const StringName &p_action) const {
float closest_similarity = 0.0;
// Find the most action with the most similar name.
- for (StringName &action : actions) {
+ for (const StringName &action : actions) {
const float similarity = String(action).similarity(p_action);
if (similarity > closest_similarity) {
@@ -261,7 +261,7 @@ void InputMap::load_from_project_settings() {
List<PropertyInfo> pinfo;
ProjectSettings::get_singleton()->get_property_list(&pinfo);
- for (PropertyInfo &pi : pinfo) {
+ for (const PropertyInfo &pi : pinfo) {
if (!pi.name.begins_with("input/")) {
continue;
}
diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp
index e30a8dfdd0..8234adea06 100644
--- a/core/io/dir_access.cpp
+++ b/core/io/dir_access.cpp
@@ -93,7 +93,7 @@ static Error _erase_recursive(DirAccess *da) {
da->list_dir_end();
- for (String &E : dirs) {
+ for (const String &E : dirs) {
Error err = da->change_dir(E);
if (err == OK) {
err = _erase_recursive(da);
@@ -114,7 +114,7 @@ static Error _erase_recursive(DirAccess *da) {
}
}
- for (String &E : files) {
+ for (const String &E : files) {
Error err = da->remove(da->get_current_dir().plus_file(E));
if (err) {
return err;
@@ -362,7 +362,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
list_dir_end();
- for (String &rel_path : dirs) {
+ for (const String &rel_path : dirs) {
String target_dir = p_to + rel_path;
if (!p_target_da->dir_exists(target_dir)) {
Error err = p_target_da->make_dir(target_dir);
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index b0bd328d21..b9fc416f65 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -35,7 +35,7 @@
bool ImageFormatLoader::recognize(const String &p_extension) const {
List<String> extensions;
get_recognized_extensions(&extensions);
- for (String &E : extensions) {
+ for (const String &E : extensions) {
if (E.nocasecmp_to(p_extension) == 0) {
return true;
}
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 132c69b7da..cd1b6d1994 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -252,7 +252,7 @@ Array IP::_get_local_addresses() const {
Array addresses;
List<IPAddress> ip_addresses;
get_local_addresses(&ip_addresses);
- for (IPAddress &E : ip_addresses) {
+ for (const IPAddress &E : ip_addresses) {
addresses.push_back(E);
}
diff --git a/core/io/json.cpp b/core/io/json.cpp
index 0381b78172..5823afbdcd 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -122,7 +122,7 @@ String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_
}
bool first_key = true;
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
if (first_key) {
first_key = false;
} else {
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 34d37dc99b..4a1d3e5212 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -1358,7 +1358,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
obj->get_property_list(&props);
int pc = 0;
- for (PropertyInfo &E : props) {
+ for (const PropertyInfo &E : props) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -1372,7 +1372,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
- for (PropertyInfo &E : props) {
+ for (const PropertyInfo &E : props) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -1418,7 +1418,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
/*
CharString utf8 = E->->utf8();
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index ee49335f55..80610e12cb 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -917,7 +917,7 @@ void MultiplayerAPI::_del_peer(int p_id) {
// Some refactoring is needed to make this faster and do paths GC.
List<NodePath> keys;
path_send_cache.get_key_list(&keys);
- for (NodePath &E : keys) {
+ for (const NodePath &E : keys) {
PathSentCache *psc = path_send_cache.getptr(E);
psc->confirmed_peers.erase(p_id);
}
diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp
index ec43ea9311..4a76f0191d 100644
--- a/core/io/packed_data_container.cpp
+++ b/core/io/packed_data_container.cpp
@@ -268,7 +268,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
d.get_key_list(&keys);
List<DictKey> sortk;
- for (Variant &key : keys) {
+ for (const Variant &key : keys) {
DictKey dk;
dk.hash = key.hash();
dk.key = key;
@@ -278,7 +278,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
sortk.sort();
int idx = 0;
- for (DictKey &E : sortk) {
+ for (const DictKey &E : sortk) {
encode_uint32(E.hash, &tmpdata.write[pos + 8 + idx * 12 + 0]);
uint32_t ofs = _pack(E.key, tmpdata, string_cache);
encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 4]);
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index 695988bd71..727611a573 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -165,7 +165,7 @@ Error Resource::copy_from(const Ref<Resource> &p_resource) {
List<PropertyInfo> pi;
p_resource->get_property_list(&pi);
- for (PropertyInfo &E : pi) {
+ for (const PropertyInfo &E : pi) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -201,7 +201,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
r->local_scene = p_for_scene;
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -233,7 +233,7 @@ void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, R
local_scene = p_for_scene;
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -259,7 +259,7 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
Ref<Resource> r = (Resource *)ClassDB::instantiate(get_class());
ERR_FAIL_COND_V(r.is_null(), Ref<Resource>());
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -317,7 +317,7 @@ uint32_t Resource::hash_edited_version() const {
List<PropertyInfo> plist;
get_property_list(&plist);
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (E.usage & PROPERTY_USAGE_STORAGE && E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) {
RES res = get(E.name);
if (res.is_valid()) {
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 81ba5cc68d..5cdb4d74a7 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1054,7 +1054,7 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String
extensions.sort();
- for (String &E : extensions) {
+ for (const String &E : extensions) {
String ext = E.to_lower();
p_extensions->push_back(ext);
}
@@ -1065,7 +1065,7 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_exten
ClassDB::get_resource_base_extensions(&extensions);
extensions.sort();
- for (String &E : extensions) {
+ for (const String &E : extensions) {
String ext = E.to_lower();
p_extensions->push_back(ext);
}
@@ -1603,7 +1603,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
/*
if (!_check_type(dict[E]))
continue;
@@ -1760,7 +1760,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
res->get_property_list(&property_list);
- for (PropertyInfo &E : property_list) {
+ for (const PropertyInfo &E : property_list) {
if (E.usage & PROPERTY_USAGE_STORAGE) {
Variant value = res->get(E.name);
if (E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
@@ -1798,7 +1798,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
Dictionary d = p_variant;
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
_find_resources(E);
Variant v = d[E];
_find_resources(v);
@@ -1909,14 +1909,14 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
List<ResourceData> resources;
{
- for (RES &E : saved_resources) {
+ for (const RES &E : saved_resources) {
ResourceData &rd = resources.push_back(ResourceData())->get();
rd.type = E->get_class();
List<PropertyInfo> property_list;
E->get_property_list(&property_list);
- for (PropertyInfo &F : property_list) {
+ for (const PropertyInfo &F : property_list) {
if (skip_editor && F.name.begins_with("__editor")) {
continue;
}
@@ -2024,15 +2024,14 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
Vector<uint64_t> ofs_table;
//now actually save the resources
- for (ResourceData &rd : resources) {
+ for (const ResourceData &rd : resources) {
ofs_table.push_back(f->get_position());
save_unicode_string(f, rd.type);
f->store_32(rd.properties.size());
- for (Property &F : rd.properties) {
- Property &p = F;
+ for (const Property &p : rd.properties) {
f->store_32(p.name_idx);
- write_variant(f, p.value, resource_map, external_resources, string_map, F.pi);
+ write_variant(f, p.value, resource_map, external_resources, string_map, p.pi);
}
}
diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp
index e7c0176e5a..1e166015b0 100644
--- a/core/io/resource_importer.cpp
+++ b/core/io/resource_importer.cpp
@@ -148,7 +148,7 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension
for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
- for (String &F : local_exts) {
+ for (const String &F : local_exts) {
if (!found.has(F)) {
p_extensions->push_back(F);
found.insert(F);
@@ -177,7 +177,7 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
- for (String &F : local_exts) {
+ for (const String &F : local_exts) {
if (!found.has(F)) {
p_extensions->push_back(F);
found.insert(F);
@@ -385,7 +385,7 @@ void ResourceFormatImporter::get_importers_for_extension(const String &p_extensi
for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
- for (String &F : local_exts) {
+ for (const String &F : local_exts) {
if (p_extension.to_lower() == F) {
r_importers->push_back(importers[i]);
}
@@ -406,7 +406,7 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St
for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
- for (String &F : local_exts) {
+ for (const String &F : local_exts) {
if (p_extension.to_lower() == F && importers[i]->get_priority() > priority) {
importer = importers[i];
priority = importers[i]->get_priority();
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 7e69b2ecab..d02d827443 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -58,7 +58,7 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_
get_recognized_extensions_for_type(p_for_type, &extensions);
}
- for (String &E : extensions) {
+ for (const String &E : extensions) {
if (E.nocasecmp_to(extension) == 0) {
return true;
}
@@ -937,7 +937,7 @@ void ResourceLoader::load_translation_remaps() {
Dictionary remaps = ProjectSettings::get_singleton()->get("internationalization/locale/translation_remaps");
List<Variant> keys;
remaps.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
Array langs = remaps[E];
Vector<String> lang_remaps;
lang_remaps.resize(langs.size());
@@ -1030,7 +1030,7 @@ void ResourceLoader::add_custom_loaders() {
List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
- for (StringName &class_name : global_classes) {
+ for (const StringName &class_name : global_classes) {
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
if (base_class == custom_loader_base_class) {
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 6158f421d1..564de5ee69 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -95,7 +95,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
bool recognized = false;
saver[i]->get_recognized_extensions(p_resource, &extensions);
- for (String &E : extensions) {
+ for (const String &E : extensions) {
if (E.nocasecmp_to(extension) == 0) {
recognized = true;
}
@@ -237,7 +237,7 @@ void ResourceSaver::add_custom_savers() {
List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
- for (StringName &class_name : global_classes) {
+ for (const StringName &class_name : global_classes) {
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
if (base_class == custom_saver_base_class) {
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index 9b506269ea..0960fe19a6 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -336,7 +336,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_
Map<Edge, RetFaceConnect> ret_edges;
List<Geometry3D::MeshData::Face> ret_faces;
- for (Face &E : faces) {
+ for (const Face &E : faces) {
Geometry3D::MeshData::Face f;
f.plane = E.plane;
@@ -439,7 +439,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_
r_mesh.faces.resize(ret_faces.size());
int idx = 0;
- for (Geometry3D::MeshData::Face &E : ret_faces) {
+ for (const Geometry3D::MeshData::Face &E : ret_faces) {
r_mesh.faces.write[idx++] = E;
}
r_mesh.edges.resize(ret_edges.size());
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index 57495a4fbd..c6ba39be94 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -359,7 +359,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
//must be alphabetically sorted for hash to compute
names.sort_custom<StringName::AlphCompare>();
- for (StringName &E : names) {
+ for (const StringName &E : names) {
ClassInfo *t = classes.getptr(E);
ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E) + "'.");
if (t->api != p_api || !t->exposed) {
@@ -388,7 +388,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
- for (StringName &F : snames) {
+ for (const StringName &F : snames) {
MethodBind *mb = t->method_map[F];
hash = hash_djb2_one_64(mb->get_name().hash(), hash);
hash = hash_djb2_one_64(mb->get_argument_count(), hash);
@@ -426,7 +426,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
- for (StringName &F : snames) {
+ for (const StringName &F : snames) {
hash = hash_djb2_one_64(F.hash(), hash);
hash = hash_djb2_one_64(t->constant_map[F], hash);
}
@@ -444,7 +444,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
- for (StringName &F : snames) {
+ for (const StringName &F : snames) {
MethodInfo &mi = t->signal_map[F];
hash = hash_djb2_one_64(F.hash(), hash);
for (int i = 0; i < mi.arguments.size(); i++) {
@@ -465,7 +465,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
- for (StringName &F : snames) {
+ for (const StringName &F : snames) {
PropertySetGet *psg = t->property_setget.getptr(F);
ERR_FAIL_COND_V(!psg, 0);
@@ -476,7 +476,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
}
//property list
- for (PropertyInfo &F : t->property_list) {
+ for (const PropertyInfo &F : t->property_list) {
hash = hash_djb2_one_64(F.name.hash(), hash);
hash = hash_djb2_one_64(F.type, hash);
hash = hash_djb2_one_64(F.hint, hash);
@@ -619,11 +619,11 @@ void ClassDB::get_method_list(const StringName &p_class, List<MethodInfo> *p_met
#ifdef DEBUG_METHODS_ENABLED
- for (MethodInfo &E : type->virtual_methods) {
+ for (const MethodInfo &E : type->virtual_methods) {
p_methods->push_back(E);
}
- for (StringName &E : type->method_order) {
+ for (const StringName &E : type->method_order) {
if (p_exclude_from_properties && type->methods_in_properties.has(E)) {
continue;
}
@@ -763,7 +763,7 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String>
while (type) {
#ifdef DEBUG_METHODS_ENABLED
- for (StringName &E : type->constant_order) {
+ for (const StringName &E : type->constant_order) {
p_constants->push_back(E);
}
#else
@@ -1073,10 +1073,12 @@ void ClassDB::get_property_list(const StringName &p_class, List<PropertyInfo> *p
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
- for (PropertyInfo pi : check->property_list) {
+ for (const PropertyInfo &pi : check->property_list) {
if (p_validator) {
- p_validator->_validate_property(pi);
- p_list->push_back(pi);
+ // Making a copy as we may modify it.
+ PropertyInfo pi_mut = pi;
+ p_validator->_validate_property(pi_mut);
+ p_list->push_back(pi_mut);
} else {
p_list->push_back(pi);
}
@@ -1428,7 +1430,7 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
- for (MethodInfo &E : check->virtual_methods) {
+ for (const MethodInfo &E : check->virtual_methods) {
p_methods->push_back(E);
}
@@ -1533,7 +1535,7 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
if (c) {
List<PropertyInfo> plist;
c->get_property_list(&plist);
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) {
if (!default_values[p_class].has(E.name)) {
Variant v = c->get(E.name);
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 0e397d8518..d552d5e5e0 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -969,7 +969,7 @@ Vector<StringName> Object::_get_meta_list_bind() const {
List<Variant> keys;
metadata.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
_metaret.push_back(E);
}
@@ -979,7 +979,7 @@ Vector<StringName> Object::_get_meta_list_bind() const {
void Object::get_meta_list(List<StringName> *p_list) const {
List<Variant> keys;
metadata.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
p_list->push_back(E);
}
}
@@ -1184,7 +1184,7 @@ Array Object::_get_signal_list() const {
get_signal_list(&signal_list);
Array ret;
- for (MethodInfo &E : signal_list) {
+ for (const MethodInfo &E : signal_list) {
ret.push_back(Dictionary(E));
}
@@ -1197,7 +1197,7 @@ Array Object::_get_signal_connection_list(const String &p_signal) const {
Array ret;
- for (Connection &c : conns) {
+ for (const Connection &c : conns) {
if (c.signal.get_name() == p_signal) {
ret.push_back(c);
}
@@ -1499,7 +1499,7 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
_clear_internal_resource_paths(E);
_clear_internal_resource_paths(d[E]);
}
@@ -1530,7 +1530,7 @@ void Object::clear_internal_resource_paths() {
get_property_list(&pinfo);
- for (PropertyInfo &E : pinfo) {
+ for (const PropertyInfo &E : pinfo) {
_clear_internal_resource_paths(get(E.name));
}
}
@@ -1665,7 +1665,7 @@ void Object::get_translatable_strings(List<String> *p_strings) const {
List<PropertyInfo> plist;
get_property_list(&plist);
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (!(E.usage & PROPERTY_USAGE_INTERNATIONALIZED)) {
continue;
}
diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp
index 5aa032192e..0fb8c7350c 100644
--- a/core/object/script_language.cpp
+++ b/core/object/script_language.cpp
@@ -63,7 +63,7 @@ Array Script::_get_script_property_list() {
Array ret;
List<PropertyInfo> list;
get_script_property_list(&list);
- for (PropertyInfo &E : list) {
+ for (const PropertyInfo &E : list) {
ret.append(E.operator Dictionary());
}
return ret;
@@ -73,7 +73,7 @@ Array Script::_get_script_method_list() {
Array ret;
List<MethodInfo> list;
get_script_method_list(&list);
- for (MethodInfo &E : list) {
+ for (const MethodInfo &E : list) {
ret.append(E.operator Dictionary());
}
return ret;
@@ -83,7 +83,7 @@ Array Script::_get_script_signal_list() {
Array ret;
List<MethodInfo> list;
get_script_signal_list(&list);
- for (MethodInfo &E : list) {
+ for (const MethodInfo &E : list) {
ret.append(E.operator Dictionary());
}
return ret;
@@ -257,7 +257,7 @@ void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) {
classes.push_back(*K);
}
classes.sort_custom<StringName::AlphCompare>();
- for (StringName &E : classes) {
+ for (const StringName &E : classes) {
r_global_classes->push_back(E);
}
}
@@ -266,7 +266,7 @@ void ScriptServer::save_global_classes() {
List<StringName> gc;
get_global_class_list(&gc);
Array gcarr;
- for (StringName &E : gc) {
+ for (const StringName &E : gc) {
Dictionary d;
d["class"] = E;
d["language"] = global_classes[E].language;
@@ -297,7 +297,7 @@ void ScriptServer::save_global_classes() {
void ScriptInstance::get_property_state(List<Pair<StringName, Variant>> &state) {
List<PropertyInfo> pinfo;
get_property_list(&pinfo);
- for (PropertyInfo &E : pinfo) {
+ for (const PropertyInfo &E : pinfo) {
if (E.usage & PROPERTY_USAGE_STORAGE) {
Pair<StringName, Variant> p;
p.first = E.name;
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 {
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);
}
}