Preallocate vectors with known size.

This commit is contained in:
Dubhghlas McLaughlin
2025-05-22 16:14:28 -05:00
parent 63ca87f9ff
commit c97ca14537
7 changed files with 285 additions and 157 deletions

View File

@@ -428,8 +428,9 @@ public:
option.location = op["location"];
if (op.has("matches")) {
PackedInt32Array matches = op["matches"];
ERR_CONTINUE(matches.size() & 1);
for (int j = 0; j < matches.size(); j += 2) {
size_t matches_size = matches.size();
ERR_CONTINUE(matches_size & 1);
for (size_t j = 0; j < matches_size; j += 2) {
option.matches.push_back(Pair<int, int>(matches[j], matches[j + 1]));
}
}