summaryrefslogtreecommitdiffstats
path: root/core/variant/variant_parser.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-04-10 17:49:14 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-04-10 17:49:14 +0200
commit7670b812333f64b8ef349797cf3e2fb26765502c (patch)
treebbfae7eca9992c0dcdf2ee237dd56f9d742d6c77 /core/variant/variant_parser.cpp
parent1f0f81049fc470fe10ddb64086c94b9c595ec81f (diff)
parent64146cb7f35b57b0974b82845674d58f9f3480b6 (diff)
downloadredot-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.cpp10
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, "]");