From 92299989bd10fd9855b6d77bc2bfabae218d1eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 26 Jul 2021 17:50:35 +0200 Subject: Use Ref references as iterators where relevant And const when possible. --- scene/animation/tween.cpp | 8 ++++---- scene/main/scene_tree.cpp | 8 ++++---- scene/main/viewport.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'scene') diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index b31c3d57f9..a57e986877 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -46,8 +46,8 @@ void Tween::start_tweeners() { ERR_FAIL_MSG("Tween without commands, aborting."); } - for (Ref E : tweeners.write[current_step]) { - E->start(); + for (Ref &tweener : tweeners.write[current_step]) { + tweener->start(); } } @@ -253,11 +253,11 @@ bool Tween::step(float p_delta) { float step_delta = rem_delta; step_active = false; - for (Ref E : tweeners.write[current_step]) { + for (Ref &tweener : tweeners.write[current_step]) { // Modified inside Tweener.step(). float temp_delta = rem_delta; // Turns to true if any Tweener returns true (i.e. is still not finished). - step_active = E->step(temp_delta) || step_active; + step_active = tweener->step(temp_delta) || step_active; step_delta = MIN(temp_delta, rem_delta); } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index adba7f1a31..ea4748da79 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -571,8 +571,8 @@ void SceneTree::finalize() { } // cleanup timers - for (Ref E : timers) { - E->release_connections(); + for (Ref &timer : timers) { + timer->release_connections(); } timers.clear(); } @@ -1146,8 +1146,8 @@ Array SceneTree::get_processed_tweens() { ret.resize(tweens.size()); int i = 0; - for (Ref E : tweens) { - ret[i] = E; + for (const Ref &tween : tweens) { + ret[i] = tween; i++; } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 4231072ed9..27e42db1bd 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -573,7 +573,7 @@ void Viewport::_process_picking() { // if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved. // while this extra event is sent, it is checked if both camera and last object and last ID did not move. If nothing changed, the event is discarded to avoid flooding with unnecessary motion events every frame bool has_mouse_event = false; - for (Ref m : physics_picking_events) { + for (const Ref &m : physics_picking_events) { if (m.is_valid()) { has_mouse_event = true; break; -- cgit v1.2.3