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

@ -816,14 +816,10 @@ impl LayoutThread {
build_state.root_stacking_context.overflow = origin; build_state.root_stacking_context.overflow = origin;
// We will not use build_state.iframe_sizes again, so it's safe to move it. // We will not use build_state.iframe_sizes again, so it's safe to move it.
let iframe_sizes = let iframe_sizes = std::mem::take(&mut build_state.iframe_sizes);
std::mem::replace(&mut build_state.iframe_sizes, FnvHashMap::default());
self.update_iframe_sizes(iframe_sizes); self.update_iframe_sizes(iframe_sizes);
rw_data.indexable_text = std::mem::replace( rw_data.indexable_text = std::mem::take(&mut build_state.indexable_text);
&mut build_state.indexable_text,
IndexableText::default(),
);
rw_data.display_list = Some(build_state.to_display_list()); rw_data.display_list = Some(build_state.to_display_list());
} }
} }
@ -1186,8 +1182,7 @@ impl LayoutThread {
reflow_result: &mut ReflowComplete, reflow_result: &mut ReflowComplete,
shared_lock: &SharedRwLock, shared_lock: &SharedRwLock,
) { ) {
reflow_result.pending_images = reflow_result.pending_images = std::mem::take(&mut *context.pending_images.lock().unwrap());
std::mem::replace(&mut *context.pending_images.lock().unwrap(), vec![]);
let mut root_flow = match self.root_flow.borrow().clone() { let mut root_flow = match self.root_flow.borrow().clone() {
Some(root_flow) => root_flow, Some(root_flow) => root_flow,

View file

@ -867,8 +867,7 @@ impl LayoutThread {
reflow_result: &mut ReflowComplete, reflow_result: &mut ReflowComplete,
shared_lock: &SharedRwLock, shared_lock: &SharedRwLock,
) { ) {
reflow_result.pending_images = reflow_result.pending_images = std::mem::take(&mut *context.pending_images.lock().unwrap());
std::mem::replace(&mut *context.pending_images.lock().unwrap(), vec![]);
match *reflow_goal { match *reflow_goal {
ReflowGoal::LayoutQuery(ref querymsg, _) => match querymsg { ReflowGoal::LayoutQuery(ref querymsg, _) => match querymsg {

View file

@ -459,7 +459,7 @@ impl Animations {
pub(crate) fn send_pending_events(&self, window: &Window) { pub(crate) fn send_pending_events(&self, window: &Window) {
// Take all of the events here, in case sending one of these events // Take all of the events here, in case sending one of these events
// triggers adding new events by forcing a layout. // 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() { if events.is_empty() {
return; return;
} }

View file

@ -95,10 +95,7 @@ impl CanvasRenderingContext2D {
} }
pub fn take_missing_image_urls(&self) -> Vec<ServoUrl> { pub fn take_missing_image_urls(&self) -> Vec<ServoUrl> {
mem::replace( std::mem::take(&mut self.canvas_state.get_missing_image_urls().borrow_mut())
&mut self.canvas_state.get_missing_image_urls().borrow_mut(),
vec![],
)
} }
pub fn get_canvas_id(&self) -> CanvasId { 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 /// `fulfill_in_flight_play_promises`, to actually fulfill the promises
/// which were taken and moved to the in-flight queue. /// which were taken and moved to the in-flight queue.
fn take_pending_play_promises(&self, result: ErrorResult) { fn take_pending_play_promises(&self, result: ErrorResult) {
let pending_play_promises = let pending_play_promises = std::mem::take(&mut *self.pending_play_promises.borrow_mut());
mem::replace(&mut *self.pending_play_promises.borrow_mut(), vec![]);
self.in_flight_play_promises_queue self.in_flight_play_promises_queue
.borrow_mut() .borrow_mut()
.push_back((pending_play_promises.into(), result)); .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 final_url = context.final_url.clone();
let script_element = context.script_element.clone(); let script_element = context.script_element.clone();
let script_kind = context.script_kind; 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(); let fetch_options = context.fetch_options.clone();
// Continue with <https://html.spec.whatwg.org/multipage/#fetch-a-classic-script> // 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 { fn decode(&mut self, chunk: Vec<u8>) -> StrTendril {
self.decoder.process(ByteTendril::from(&*chunk)); self.decoder.process(ByteTendril::from(&*chunk));
mem::replace( std::mem::take(&mut self.decoder.inner_sink_mut().output)
&mut self.decoder.inner_sink_mut().output,
Default::default(),
)
} }
fn finish(self) -> StrTendril { fn finish(self) -> StrTendril {