mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
Preallocate vectors with known size.
This commit is contained in:
@@ -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]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,11 +390,15 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E, bool p_execu
|
||||
} else {
|
||||
args.clear();
|
||||
|
||||
for (int i = 0; i < binds.size(); i++) {
|
||||
args.push_back(&binds[i]);
|
||||
size_t binds_size = binds.size();
|
||||
|
||||
args.resize(binds_size);
|
||||
|
||||
for (size_t i = 0; i < binds_size; i++) {
|
||||
args[i] = &binds[i];
|
||||
}
|
||||
|
||||
method_callback(method_callback_ud, obj, op.name, args.ptr(), binds.size());
|
||||
method_callback(method_callback_ud, obj, op.name, args.ptr(), binds_size);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
Reference in New Issue
Block a user