@@ -2248,8 +2248,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
22482248 ERR_PRINT (" Max recursion reached" );
22492249 p_store_string_func (p_store_string_ud, " {}" );
22502250 } else {
2251- List<Variant> keys;
2252- dict.get_key_list (&keys);
2251+ LocalVector<Variant> keys = dict.get_key_list ();
22532252 keys.sort_custom <StringLikeVariantOrder>();
22542253
22552254 if (keys.is_empty ()) {
@@ -2260,11 +2259,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
22602259
22612260 p_store_string_func (p_store_string_ud, " {\n " );
22622261
2263- for (List<Variant>::Element *E = keys.front (); E; E = E->next ()) {
2264- write (E->get (), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count, p_compat);
2262+ for (uint32_t i = 0 ; i < keys.size (); i++) {
2263+ const Variant &key = keys[i];
2264+ write (key, p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count, p_compat);
22652265 p_store_string_func (p_store_string_ud, " : " );
2266- write (dict[E-> get () ], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count, p_compat);
2267- if (E-> next ()) {
2266+ write (dict[key ], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count, p_compat);
2267+ if (i + 1 < keys. size ()) {
22682268 p_store_string_func (p_store_string_ud, " ,\n " );
22692269 } else {
22702270 p_store_string_func (p_store_string_ud, " \n " );
0 commit comments