mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Reduce and prevent unnecessary random-access to List
Random-access access to `List` when iterating is `O(n^2)` (`O(n)` when accessing a single element) * Removed subscript operator, in favor of a more explicit `get` * Added conversion from `Iterator` to `ConstIterator` * Remade existing operations into other solutions when applicable
This commit is contained in:
@@ -694,7 +694,7 @@ void AnimationMultiTrackKeyEdit::_key_ofs_changed(const Ref<Animation> &p_anim,
|
||||
}
|
||||
|
||||
int track = E.key;
|
||||
key_ofs_map[track][key] = to;
|
||||
key_ofs_map[track].get(key) = to;
|
||||
|
||||
if (setting) {
|
||||
return;
|
||||
@@ -3803,8 +3803,8 @@ void AnimationTrackEditor::commit_insert_queue() {
|
||||
reset_allowed = false;
|
||||
} else {
|
||||
bool some_resettable = false;
|
||||
for (int i = 0; i < insert_data.size(); i++) {
|
||||
if (track_type_is_resettable(insert_data[i].type)) {
|
||||
for (const AnimationTrackEditor::InsertData &E : insert_data) {
|
||||
if (track_type_is_resettable(E.type)) {
|
||||
some_resettable = true;
|
||||
break;
|
||||
}
|
||||
@@ -3818,21 +3818,21 @@ void AnimationTrackEditor::commit_insert_queue() {
|
||||
int num_tracks = 0;
|
||||
String last_track_query;
|
||||
bool all_bezier = true;
|
||||
for (int i = 0; i < insert_data.size(); i++) {
|
||||
if (insert_data[i].type != Animation::TYPE_VALUE && insert_data[i].type != Animation::TYPE_BEZIER) {
|
||||
for (const AnimationTrackEditor::InsertData &E : insert_data) {
|
||||
if (E.type != Animation::TYPE_VALUE && E.type != Animation::TYPE_BEZIER) {
|
||||
all_bezier = false;
|
||||
}
|
||||
|
||||
if (insert_data[i].track_idx == -1) {
|
||||
if (E.track_idx == -1) {
|
||||
++num_tracks;
|
||||
last_track_query = insert_data[i].query;
|
||||
last_track_query = E.query;
|
||||
}
|
||||
|
||||
if (insert_data[i].type != Animation::TYPE_VALUE) {
|
||||
if (E.type != Animation::TYPE_VALUE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (insert_data[i].value.get_type()) {
|
||||
switch (E.value.get_type()) {
|
||||
case Variant::INT:
|
||||
case Variant::FLOAT:
|
||||
case Variant::VECTOR2:
|
||||
@@ -5317,14 +5317,15 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) {
|
||||
Array params;
|
||||
int first_defarg = E.arguments.size() - E.default_arguments.size();
|
||||
|
||||
for (int i = 0; i < E.arguments.size(); i++) {
|
||||
int i = 0;
|
||||
for (List<PropertyInfo>::ConstIterator itr = E.arguments.begin(); itr != E.arguments.end(); ++itr, ++i) {
|
||||
if (i >= first_defarg) {
|
||||
Variant arg = E.default_arguments[i - first_defarg];
|
||||
params.push_back(arg);
|
||||
} else {
|
||||
Callable::CallError ce;
|
||||
Variant arg;
|
||||
Variant::construct(E.arguments[i].type, arg, nullptr, 0, ce);
|
||||
Variant::construct(itr->type, arg, nullptr, 0, ce);
|
||||
params.push_back(arg);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user