1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #104047 from YYF233333/dict_iter

Add const iteration support to `Dictionary`
This commit is contained in:
Thaddeus Crews
2025-03-13 08:57:23 -05:00
34 changed files with 131 additions and 179 deletions

View File

@@ -4024,11 +4024,9 @@ String String::format(const Variant &values, const String &placeholder) const {
}
} else if (values.get_type() == Variant::DICTIONARY) {
Dictionary d = values;
List<Variant> keys;
d.get_key_list(&keys);
for (const Variant &key : keys) {
new_string = new_string.replace(placeholder.replace("_", key), d[key]);
for (const KeyValue<Variant, Variant> &kv : d) {
new_string = new_string.replace(placeholder.replace("_", kv.key), kv.value);
}
} else if (values.get_type() == Variant::OBJECT) {
Object *obj = values.get_validated_object();