From 83713a38bb8ec4a5f7afcfcfb3d4dad86860559e Mon Sep 17 00:00:00 2001 From: Dor Askayo Date: Sun, 24 Sep 2023 18:09:44 +0300 Subject: [PATCH] wayland: Remove unreachable condition The value returned from clutter_frame_get_target_presentation_time() is always same as the value returned from clutter_frame_get_min_render_time_allowed() when they are called consecutively because both functions effectively return the value of frame->has_target_presentation_time. This is with the assumption that this variable is only ever modified by the same thread that also executes on_after_update(). As such, a case where the former returns FALSE after the latter returned TRUE is not possible, which means the line that sets "target_presentation_time_us = 0;" is effectively unreachable. Acknowledging this fact allows the call to clutter_frame_get_target_presentation_time() to be moved outside the "else" case and into the "if" condition itself. This is done in preparation for the next commits. No change in behavior. Part-of: --- src/wayland/meta-wayland.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index ac7f0e250..59338cd0c 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -298,6 +298,7 @@ on_after_update (ClutterStage *stage, FrameCallbackSource *frame_callback_source; GSource *source; int64_t min_render_time_allowed_us; + int64_t target_presentation_time_us; if (!META_IS_BACKEND_NATIVE (backend)) { @@ -312,20 +313,17 @@ on_after_update (ClutterStage *stage, if (meta_frame_native_had_kms_update (frame_native) || !clutter_frame_get_min_render_time_allowed (frame, - &min_render_time_allowed_us)) + &min_render_time_allowed_us) || + !clutter_frame_get_target_presentation_time (frame, + &target_presentation_time_us)) { g_source_set_ready_time (source, -1); emit_frame_callbacks_for_stage_view (compositor, stage_view); } else { - int64_t target_presentation_time_us; int64_t source_ready_time_us; - if (!clutter_frame_get_target_presentation_time (frame, - &target_presentation_time_us)) - target_presentation_time_us = 0; - if (g_source_get_ready_time (source) != -1 && frame_callback_source->target_presentation_time_us < target_presentation_time_us)