diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-10 17:49:14 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-10 17:49:14 +0200 |
commit | 7670b812333f64b8ef349797cf3e2fb26765502c (patch) | |
tree | bbfae7eca9992c0dcdf2ee237dd56f9d742d6c77 /core/variant/variant_parser.cpp | |
parent | 1f0f81049fc470fe10ddb64086c94b9c595ec81f (diff) | |
parent | 64146cb7f35b57b0974b82845674d58f9f3480b6 (diff) | |
download | redot-engine-7670b812333f64b8ef349797cf3e2fb26765502c.tar.gz |
Merge pull request #86518 from AThousandShips/array_iter
[Core] Add iteration support to `Array`
Diffstat (limited to 'core/variant/variant_parser.cpp')
-rw-r--r-- | core/variant/variant_parser.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index fa91758fff..9fafaa9ee9 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -2012,12 +2012,14 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_recursion_count++; p_store_string_func(p_store_string_ud, "["); - int len = array.size(); - for (int i = 0; i < len; i++) { - if (i > 0) { + bool first = true; + for (const Variant &var : array) { + if (first) { + first = false; + } else { p_store_string_func(p_store_string_ud, ", "); } - write(array[i], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count); + write(var, p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count); } p_store_string_func(p_store_string_ud, "]"); |