From d5c2f20d55c45a70f4cf536b9f7441e1eb67c48e Mon Sep 17 00:00:00 2001 From: Dor Askayo Date: Mon, 25 Sep 2023 12:41:48 +0300 Subject: [PATCH] wayland: Flatten logic in on_after_update() Slightly improves the cognitive complexity of the function. No change in behavior. Part-of: --- src/wayland/meta-wayland.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index a269462b5..3b76281be 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -297,6 +297,7 @@ on_after_update (ClutterStage *stage, GSource *source; int64_t min_render_time_allowed_us; int64_t target_presentation_time_us; + int64_t frame_deadline_us; if (!META_IS_BACKEND_NATIVE (backend)) { @@ -316,27 +317,23 @@ on_after_update (ClutterStage *stage, { g_source_set_ready_time (source, -1); emit_frame_callbacks_for_stage_view (compositor, stage_view); + return; } - else + + frame_deadline_us = target_presentation_time_us - + min_render_time_allowed_us; + + if (frame_deadline_us <= g_get_monotonic_time ()) { - int64_t frame_deadline_us; - - frame_deadline_us = target_presentation_time_us - - min_render_time_allowed_us; - - if (frame_deadline_us <= g_get_monotonic_time ()) - { - g_source_set_ready_time (source, -1); - emit_frame_callbacks_for_stage_view (compositor, stage_view); - } - else - { - if (g_source_get_ready_time (source) != -1) - return; - - g_source_set_ready_time (source, frame_deadline_us); - } + g_source_set_ready_time (source, -1); + emit_frame_callbacks_for_stage_view (compositor, stage_view); + return; } + + if (g_source_get_ready_time (source) != -1) + return; + + g_source_set_ready_time (source, frame_deadline_us); #else emit_frame_callbacks_for_stage_view (compositor, stage_view); #endif