clippy: Fix mem_replace_with_default warnings (#31921)

This commit is contained in:
Oluwatobi Sofela 2024-03-28 14:10:37 +01:00 committed by GitHub
parent 7100465d1a
commit 66ad795014
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 9 additions and 22 deletions

View file

@ -459,7 +459,7 @@ impl Animations {
pub(crate) fn send_pending_events(&self, window: &Window) {
// Take all of the events here, in case sending one of these events
// triggers adding new events by forcing a layout.
let events = std::mem::replace(&mut *self.pending_events.borrow_mut(), Vec::new());
let events = std::mem::take(&mut *self.pending_events.borrow_mut());
if events.is_empty() {
return;
}

View file

@ -95,10 +95,7 @@ impl CanvasRenderingContext2D {
}
pub fn take_missing_image_urls(&self) -> Vec<ServoUrl> {
mem::replace(
&mut self.canvas_state.get_missing_image_urls().borrow_mut(),
vec![],
)
std::mem::take(&mut self.canvas_state.get_missing_image_urls().borrow_mut())
}
pub fn get_canvas_id(&self) -> CanvasId {

View file

@ -1191,8 +1191,7 @@ impl HTMLMediaElement {
/// `fulfill_in_flight_play_promises`, to actually fulfill the promises
/// which were taken and moved to the in-flight queue.
fn take_pending_play_promises(&self, result: ErrorResult) {
let pending_play_promises =
mem::replace(&mut *self.pending_play_promises.borrow_mut(), vec![]);
let pending_play_promises = std::mem::take(&mut *self.pending_play_promises.borrow_mut());
self.in_flight_play_promises_queue
.borrow_mut()
.push_back((pending_play_promises.into(), result));

View file

@ -106,7 +106,7 @@ unsafe extern "C" fn off_thread_compilation_callback(
let final_url = context.final_url.clone();
let script_element = context.script_element.clone();
let script_kind = context.script_kind;
let script = replace(&mut context.script_text, String::new());
let script = std::mem::take(&mut context.script_text);
let fetch_options = context.fetch_options.clone();
// Continue with <https://html.spec.whatwg.org/multipage/#fetch-a-classic-script>

View file

@ -1401,10 +1401,7 @@ impl NetworkDecoder {
fn decode(&mut self, chunk: Vec<u8>) -> StrTendril {
self.decoder.process(ByteTendril::from(&*chunk));
mem::replace(
&mut self.decoder.inner_sink_mut().output,
Default::default(),
)
std::mem::take(&mut self.decoder.inner_sink_mut().output)
}
fn finish(self) -> StrTendril {