diff options
author | hop311 <hop3114@gmail.com> | 2024-04-21 00:16:45 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-04-21 01:22:00 +0200 |
commit | 5192708bda86625a40ce67ff297dca8138f9cc13 (patch) | |
tree | edba52a563952d2cf14c6d8f2a4995ac8017c147 /extension/src/openvic-extension/classes/GFXPieChartTexture.hpp | |
parent | 2d5454c668fc866023c41f07ceed263b2c1ff237 (diff) |
Pre-allocate and use std::move for Godot Arrays and Dictionariesarray-dict-tweaks
Diffstat (limited to 'extension/src/openvic-extension/classes/GFXPieChartTexture.hpp')
-rw-r--r-- | extension/src/openvic-extension/classes/GFXPieChartTexture.hpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp index f1fbe1a..8683b10 100644 --- a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp +++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp @@ -54,12 +54,14 @@ namespace OpenVic { return lhs.first < rhs.first; }); godot_pie_chart_data_t array; - for (auto const& [key, val] : sorted_dist) { + ERR_FAIL_COND_V(array.resize(sorted_dist.size()) != OK, {}); + for (size_t idx = 0; idx < array.size(); ++idx) { + auto const& [key, val] = sorted_dist[idx]; Dictionary sub_dict; sub_dict[_slice_identifier_key()] = Utilities::std_view_to_godot_string(key->get_identifier()); sub_dict[_slice_colour_key()] = Utilities::to_godot_color(key->get_colour()); sub_dict[_slice_weight_key()] = val.to_float(); - array.push_back(sub_dict); + array[idx] = std::move(sub_dict); } return array; } |