Rework if/else into early returns

Signed-off-by: Michael Rees <mrees@noeontheend.com>
This commit is contained in:
Michael Rees 2025-05-23 21:52:37 -05:00
parent 32721f61d3
commit 3d705c1d20
No known key found for this signature in database
GPG key ID: F39BD6DE838A5F85

View file

@ -1521,7 +1521,8 @@ impl HTMLMediaElement {
self.earliest_possible_position(),
/* approximate_for_speed*/ false,
);
} else {
return;
}
// Step 2.
// The **ended playback** condition is implemented inside of
// the HTMLMediaElementMethods::Ended method
@ -1557,7 +1558,6 @@ impl HTMLMediaElement {
// https://html.spec.whatwg.org/multipage/#dom-media-have_current_data
self.change_ready_state(ReadyState::HaveCurrentData);
}
}
fn playback_end(&self) {
// https://html.spec.whatwg.org/multipage/#media-data-processing-steps-list
@ -1565,7 +1565,9 @@ impl HTMLMediaElement {
// an unsupported format, or can otherwise not be rendered at all"
if self.ready_state.get() < ReadyState::HaveMetadata {
self.queue_dedicated_media_source_failure_steps();
} else {
return;
}
// https://html.spec.whatwg.org/multipage/#reaches-the-end
match self.direction_of_playback() {
PlaybackDirection::Forwards => self.end_of_playback_in_forwards_direction(),
@ -1580,7 +1582,6 @@ impl HTMLMediaElement {
},
}
}
}
fn playback_error(&self, error: &str, can_gc: CanGc) {
error!("Player error: {:?}", error);