Skip to content

Commit

Permalink
Using iterator pattern instead of List::Element *.
Browse files Browse the repository at this point in the history
  • Loading branch information
YYF233333 committed Feb 3, 2025
1 parent 1586c56 commit a669c2a
Show file tree
Hide file tree
Showing 37 changed files with 155 additions and 179 deletions.
4 changes: 2 additions & 2 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1452,8 +1452,8 @@ void ProjectSettings::_add_builtin_input_map() {
Array events;

// Convert list of input events into array
for (List<Ref<InputEvent>>::Element *I = E.value.front(); I; I = I->next()) {
events.push_back(I->get());
for (const Ref<InputEvent> &I : E.value) {
events.push_back(I);
}

Dictionary action;
Expand Down
8 changes: 4 additions & 4 deletions core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ bool OS::is_restart_on_exit_set() const {
Vector<String> OS::get_restart_on_exit_arguments() const {
List<String> args = ::OS::get_singleton()->get_restart_on_exit_arguments();
Vector<String> args_vector;
for (List<String>::Element *E = args.front(); E; E = E->next()) {
args_vector.push_back(E->get());
for (const String &E : args) {
args_vector.push_back(E);
}

return args_vector;
Expand Down Expand Up @@ -1876,8 +1876,8 @@ Vector<String> Engine::get_singleton_list() const {
List<::Engine::Singleton> singletons;
::Engine::get_singleton()->get_singletons(&singletons);
Vector<String> ret;
for (List<::Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
ret.push_back(E->get().name);
for (const ::Engine::Singleton &E : singletons) {
ret.push_back(E.name);
}
return ret;
}
Expand Down
8 changes: 4 additions & 4 deletions core/extension/extension_api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,14 +970,14 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
Array values;
List<StringName> enum_constant_list;
ClassDB::get_enum_constants(class_name, F, &enum_constant_list, true);
for (List<StringName>::Element *G = enum_constant_list.front(); G; G = G->next()) {
for (const StringName &G : enum_constant_list) {
Dictionary d3;
d3["name"] = String(G->get());
d3["value"] = ClassDB::get_integer_constant(class_name, G->get());
d3["name"] = String(G);
d3["value"] = ClassDB::get_integer_constant(class_name, G);

if (p_include_docs) {
for (const DocData::ConstantDoc &constant_doc : class_doc->constants) {
if (constant_doc.name == G->get()) {
if (constant_doc.name == G) {
d3["description"] = fix_doc_description(constant_doc.description);
break;
}
Expand Down
4 changes: 1 addition & 3 deletions core/math/geometry_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ Vector<Vector<Vector2>> Geometry2D::decompose_polygon_in_convex(const Vector<Poi

decomp.resize(out_poly.size());
int idx = 0;
for (List<TPPLPoly>::Element *I = out_poly.front(); I; I = I->next()) {
TPPLPoly &tp = I->get();

for (TPPLPoly &tp : out_poly) {
decomp.write[idx].resize(tp.GetNumPoints());

for (int64_t i = 0; i < tp.GetNumPoints(); i++) {
Expand Down
4 changes: 2 additions & 2 deletions core/object/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,8 +1080,8 @@ TypedArray<Dictionary> Object::_get_method_list_bind() const {
get_method_list(&ml);
TypedArray<Dictionary> ret;

for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) {
Dictionary d = E->get();
for (const MethodInfo &E : ml) {
Dictionary d = E;
//va.push_back(d);
ret.push_back(d);
}
Expand Down
7 changes: 3 additions & 4 deletions core/string/translation_po.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void TranslationPO::print_translation_map() {

List<StringName> id_l;
inner_map.get_key_list(&id_l);
for (List<StringName>::Element *E2 = id_l.front(); E2; E2 = E2->next()) {
StringName id = E2->get();
for (const StringName &id : id_l) {
file->store_line("msgid: " + String::utf8(String(id).utf8()));
for (int i = 0; i < inner_map[id].size(); i++) {
file->store_line("msgstr[" + String::num_int64(i) + "]: " + String::utf8(String(inner_map[id][i]).utf8()));
Expand Down Expand Up @@ -94,8 +93,8 @@ void TranslationPO::_set_messages(const Dictionary &p_messages) {
HashMap<StringName, Vector<StringName>> temp_map;
List<Variant> id_l;
id_str_map.get_key_list(&id_l);
for (List<Variant>::Element *E2 = id_l.front(); E2; E2 = E2->next()) {
StringName id = E2->get();
for (const Variant &E2 : id_l) {
StringName id = E2;
temp_map[id] = id_str_map[id];
}

Expand Down
6 changes: 3 additions & 3 deletions core/variant/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,10 +1659,10 @@ String Variant::stringify(int recursion_count) const {

Vector<_VariantStrPair> pairs;

for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
for (const Variant &E : keys) {
_VariantStrPair sp;
sp.key = stringify_variant_clean(E->get(), recursion_count);
sp.value = stringify_variant_clean(d[E->get()], recursion_count);
sp.key = stringify_variant_clean(E, recursion_count);
sp.value = stringify_variant_clean(d[E], recursion_count);

pairs.push_back(sp);
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/storage/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,8 +1468,8 @@ void TextureStorage::texture_debug_usage(List<RS::TextureInfo> *r_info) {
List<RID> textures;
texture_owner.get_owned_list(&textures);

for (List<RID>::Element *E = textures.front(); E; E = E->next()) {
Texture *t = texture_owner.get_or_null(E->get());
for (const RID &E : textures) {
Texture *t = texture_owner.get_or_null(E);
if (!t) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1251,12 +1251,12 @@ void AnimationMultiTrackKeyEdit::_get_property_list(List<PropertyInfo> *p_list)
if (ap) {
List<StringName> anims;
ap->get_animation_list(&anims);
for (List<StringName>::Element *G = anims.front(); G; G = G->next()) {
for (const StringName &G : anims) {
if (!animations.is_empty()) {
animations += ",";
}

animations += String(G->get());
animations += String(G);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1459,11 +1459,11 @@ void ConnectionsDock::update_tree() {
List<MethodInfo> base_signals;
base->get_script_signal_list(&base_signals);
HashSet<String> base_signal_names;
for (List<MethodInfo>::Element *F = base_signals.front(); F; F = F->next()) {
base_signal_names.insert(F->get().name);
for (const MethodInfo &F : base_signals) {
base_signal_names.insert(F.name);
}
for (List<MethodInfo>::Element *F = class_signals.front(); F; F = F->next()) {
if (base_signal_names.has(F->get().name)) {
for (const MethodInfo &F : class_signals) {
if (base_signal_names.has(F.name)) {
class_signals.erase(F);
}
}
Expand Down
6 changes: 2 additions & 4 deletions editor/create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ void CreateDialog::_fill_type_list() {

EditorData &ed = EditorNode::get_editor_data();

for (List<StringName>::Element *I = complete_type_list.front(); I; I = I->next()) {
StringName type = I->get();
for (const StringName &type : complete_type_list) {
if (!_should_hide_type(type)) {
type_list.push_back(type);

Expand Down Expand Up @@ -216,8 +215,7 @@ void CreateDialog::_update_search() {
float highest_score = 0.0f;
StringName best_match;

for (List<StringName>::Element *I = type_list.front(); I; I = I->next()) {
StringName candidate = I->get();
for (const StringName &candidate : type_list) {
if (empty_search || search_text.is_subsequence_ofn(candidate)) {
_add_type(candidate, ClassDB::class_exists(candidate) ? TypeCategory::CPP_TYPE : TypeCategory::OTHER_TYPE);

Expand Down
4 changes: 1 addition & 3 deletions editor/debugger/debug_adapter/debug_adapter_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ Dictionary DebugAdapterParser::req_initialize(const Dictionary &p_params) const
// Send all current breakpoints
List<String> breakpoints;
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
for (List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
String breakpoint = E->get();

for (const String &breakpoint : breakpoints) {
String path = breakpoint.left(breakpoint.find_char(':', 6)); // Skip initial part of path, aka "res://"
int line = breakpoint.substr(path.size()).to_int();

Expand Down
68 changes: 32 additions & 36 deletions editor/debugger/debug_adapter/debug_adapter_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,82 +904,81 @@ void DebugAdapterProtocol::notify_process() {
String launch_mode = _current_peer->attached ? "attach" : "launch";

Dictionary event = parser->ev_process(launch_mode);
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
E->get()->res_queue.push_back(event);
for (const Ref<DAPeer> &E : clients) {
E->res_queue.push_back(event);
}
}

void DebugAdapterProtocol::notify_terminated() {
Dictionary event = parser->ev_terminated();
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
if ((_current_request == "launch" || _current_request == "restart") && _current_peer == E->get()) {
for (const Ref<DAPeer> &E : clients) {
if ((_current_request == "launch" || _current_request == "restart") && _current_peer == E) {
continue;
}
E->get()->res_queue.push_back(event);
E->res_queue.push_back(event);
}
}

void DebugAdapterProtocol::notify_exited(const int &p_exitcode) {
Dictionary event = parser->ev_exited(p_exitcode);
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
if ((_current_request == "launch" || _current_request == "restart") && _current_peer == E->get()) {
for (const Ref<DAPeer> &E : clients) {
if ((_current_request == "launch" || _current_request == "restart") && _current_peer == E) {
continue;
}
E->get()->res_queue.push_back(event);
E->res_queue.push_back(event);
}
}

void DebugAdapterProtocol::notify_stopped_paused() {
Dictionary event = parser->ev_stopped_paused();
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
E->get()->res_queue.push_back(event);
for (const Ref<DAPeer> &E : clients) {
E->res_queue.push_back(event);
}
}

void DebugAdapterProtocol::notify_stopped_exception(const String &p_error) {
Dictionary event = parser->ev_stopped_exception(p_error);
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
E->get()->res_queue.push_back(event);
for (const Ref<DAPeer> &E : clients) {
E->res_queue.push_back(event);
}
}

void DebugAdapterProtocol::notify_stopped_breakpoint(const int &p_id) {
Dictionary event = parser->ev_stopped_breakpoint(p_id);
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
E->get()->res_queue.push_back(event);
for (const Ref<DAPeer> &E : clients) {
E->res_queue.push_back(event);
}
}

void DebugAdapterProtocol::notify_stopped_step() {
Dictionary event = parser->ev_stopped_step();
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
E->get()->res_queue.push_back(event);
for (const Ref<DAPeer> &E : clients) {
E->res_queue.push_back(event);
}
}

void DebugAdapterProtocol::notify_continued() {
Dictionary event = parser->ev_continued();
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
if (_current_request == "continue" && E->get() == _current_peer) {
for (const Ref<DAPeer> &E : clients) {
if (_current_request == "continue" && E == _current_peer) {
continue;
}
E->get()->res_queue.push_back(event);
E->res_queue.push_back(event);
}

reset_stack_info();
}

void DebugAdapterProtocol::notify_output(const String &p_message, RemoteDebugger::MessageType p_type) {
Dictionary event = parser->ev_output(p_message, p_type);
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
E->get()->res_queue.push_back(event);
for (const Ref<DAPeer> &E : clients) {
E->res_queue.push_back(event);
}
}

void DebugAdapterProtocol::notify_custom_data(const String &p_msg, const Array &p_data) {
Dictionary event = parser->ev_custom_data(p_msg, p_data);
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
Ref<DAPeer> peer = E->get();
for (const Ref<DAPeer> &peer : clients) {
if (peer->supportsCustomData) {
peer->res_queue.push_back(event);
}
Expand All @@ -988,11 +987,11 @@ void DebugAdapterProtocol::notify_custom_data(const String &p_msg, const Array &

void DebugAdapterProtocol::notify_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled) {
Dictionary event = parser->ev_breakpoint(p_breakpoint, p_enabled);
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
if (_current_request == "setBreakpoints" && E->get() == _current_peer) {
for (const Ref<DAPeer> &E : clients) {
if (_current_request == "setBreakpoints" && E == _current_peer) {
continue;
}
E->get()->res_queue.push_back(event);
E->res_queue.push_back(event);
}
}

Expand All @@ -1011,8 +1010,7 @@ Array DebugAdapterProtocol::update_breakpoints(const String &p_path, const Array
}

// Remove breakpoints
for (List<DAP::Breakpoint>::Element *E = breakpoint_list.front(); E; E = E->next()) {
DAP::Breakpoint b = E->get();
for (const DAP::Breakpoint &b : breakpoint_list) {
if (b.source.path == p_path && !p_lines.has(b.line)) {
EditorDebuggerNode::get_singleton()->get_default_debugger()->_set_breakpoint(p_path, b.line, false);
}
Expand Down Expand Up @@ -1130,8 +1128,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_vars(const int &p_size) {
frame.id = _current_frame;
ERR_FAIL_COND(!stackframe_list.has(frame));
List<int> scope_ids = stackframe_list.find(frame)->value;
for (List<int>::Element *E = scope_ids.front(); E; E = E->next()) {
int var_id = E->get();
for (const int var_id : scope_ids) {
if (variable_list.has(var_id)) {
variable_list.find(var_id)->value.clear();
} else {
Expand Down Expand Up @@ -1192,8 +1189,7 @@ void DebugAdapterProtocol::poll() {
on_client_connected();
}
List<Ref<DAPeer>> to_delete;
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
Ref<DAPeer> peer = E->get();
for (const Ref<DAPeer> &peer : clients) {
peer->connection->poll();
StreamPeerTCP::Status status = peer->connection->get_status();
if (status == StreamPeerTCP::STATUS_NONE || status == StreamPeerTCP::STATUS_ERROR) {
Expand All @@ -1211,8 +1207,8 @@ void DebugAdapterProtocol::poll() {
}
}

for (List<Ref<DAPeer>>::Element *E = to_delete.front(); E; E = E->next()) {
on_client_disconnected(E->get());
for (const Ref<DAPeer> &E : to_delete) {
on_client_disconnected(E);
}
to_delete.clear();
}
Expand All @@ -1225,8 +1221,8 @@ Error DebugAdapterProtocol::start(int p_port, const IPAddress &p_bind_ip) {
}

void DebugAdapterProtocol::stop() {
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
E->get()->connection->disconnect_from_host();
for (const Ref<DAPeer> &E : clients) {
E->connection->disconnect_from_host();
}

clients.clear();
Expand Down
13 changes: 6 additions & 7 deletions editor/doc_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ static Variant get_documentation_default_value(const StringName &p_class_name, c
// Cannot get default value of classes that can't be instantiated
List<StringName> inheriting_classes;
ClassDB::get_direct_inheriters_from_class(p_class_name, &inheriting_classes);
for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) {
if (ClassDB::can_instantiate(E2->get())) {
default_value = ClassDB::class_get_default_property_value(E2->get(), p_property_name, &r_default_value_valid);
for (const StringName &E2 : inheriting_classes) {
if (ClassDB::can_instantiate(E2)) {
default_value = ClassDB::class_get_default_property_value(E2, p_property_name, &r_default_value_valid);
if (r_default_value_valid) {
break;
}
Expand Down Expand Up @@ -648,11 +648,10 @@ void DocTools::generate(BitField<GenerateFlags> p_flags) {
ClassDB::get_signal_list(name, &signal_list, true);

if (signal_list.size()) {
for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) {
for (const MethodInfo &EV : signal_list) {
DocData::MethodDoc signal;
signal.name = EV->get().name;
for (List<PropertyInfo>::Element *EA = EV->get().arguments.front(); EA; EA = EA->next()) {
const PropertyInfo &arginfo = EA->get();
signal.name = EV.name;
for (const PropertyInfo &arginfo : EV.arguments) {
DocData::ArgumentDoc argument;
DocData::argument_doc_from_arginfo(argument, arginfo);

Expand Down
3 changes: 1 addition & 2 deletions editor/editor_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,7 @@ void EditorData::instantiate_object_properties(Object *p_object) {
List<PropertyInfo> pinfo;
p_object->get_property_list(&pinfo);

for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
PropertyInfo pi = E->get();
for (const PropertyInfo &pi : pinfo) {
if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) {
Object *prop = ClassDB::instantiate(pi.class_name);
p_object->set(pi.name, prop);
Expand Down
Loading

0 comments on commit a669c2a

Please sign in to comment.