diff options
author | Rosemary Ajayi <okhuomonajayi54@gmail.com> | 2024-03-20 18:41:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-20 18:41:07 +0000 |
commit | 058319aa0b9dbf1916dd87f27171bccd051be3e3 (patch) | |
tree | 0f3ba0d1322b8ac378fb37805f7720f00280625e /components/script | |
parent | 3651b650c48ba8cf1b8f00f4be9705ac11b68a8c (diff) | |
download | servo-058319aa0b9dbf1916dd87f27171bccd051be3e3.tar.gz servo-058319aa0b9dbf1916dd87f27171bccd051be3e3.zip |
clippy: Fix some clippy problems in `components/script` (#31778)
* fix clippy problems in stylesheet
* fix clippy problems in task_manager
* fix clippy problems in task_queue
* fix clippy problems in task_queue
* fix clippy problems in file_reading
* fix clippy problems in dom_manipulation
* fix clippy problems in gamepad
* fix clippy problems in networking
* fix clippy problems in performance
* fix clippy problems in port_message
* fix clippy problems in port_message
* fix clippy problems in timer
* fix clippy problems in stylesheet
* fix clippy problems
* fix clippy problems
* fix clippy problems
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/stylesheet_loader.rs | 7 | ||||
-rw-r--r-- | components/script/task_manager.rs | 2 | ||||
-rw-r--r-- | components/script/task_queue.rs | 10 | ||||
-rw-r--r-- | components/script/task_source/dom_manipulation.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/file_reading.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/gamepad.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/networking.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/performance_timeline.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/port_message.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/remote_event.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/timer.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/websocket.rs | 2 |
12 files changed, 18 insertions, 19 deletions
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index 3b6c14525df..8ba0760840f 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use std::mem; use std::sync::atomic::AtomicBool; use std::sync::Mutex; @@ -134,14 +133,14 @@ impl FetchResponseListener for StylesheetContext { }); let data = if is_css { - mem::replace(&mut self.data, vec![]) + std::mem::take(&mut self.data) } else { vec![] }; // TODO: Get the actual value. http://dev.w3.org/csswg/css-syntax/#environment-encoding let environment_encoding = UTF_8; - let protocol_encoding_label = metadata.charset.as_ref().map(|s| &**s); + let protocol_encoding_label = metadata.charset.as_deref(); let final_url = metadata.final_url; let win = window_from_node(&*elem); @@ -277,7 +276,7 @@ impl<'a> StylesheetLoader<'a> { .downcast::<HTMLLinkElement>() .map(HTMLLinkElement::get_request_generation_id); let context = ::std::sync::Arc::new(Mutex::new(StylesheetContext { - elem: Trusted::new(&*self.elem), + elem: Trusted::new(self.elem), source: source, url: url.clone(), metadata: None, diff --git a/components/script/task_manager.rs b/components/script/task_manager.rs index a732f8d5dda..d3671f682d2 100644 --- a/components/script/task_manager.rs +++ b/components/script/task_manager.rs @@ -194,7 +194,7 @@ impl TaskManager { pub fn task_canceller(&self, name: TaskSourceName) -> TaskCanceller { let mut flags = self.task_cancellers.borrow_mut(); - let cancel_flag = flags.entry(name).or_insert(Default::default()); + let cancel_flag = flags.entry(name).or_default(); TaskCanceller { cancelled: cancel_flag.clone(), } diff --git a/components/script/task_queue.rs b/components/script/task_queue.rs index a3de0c4b52f..1fac477865e 100644 --- a/components/script/task_queue.rs +++ b/components/script/task_queue.rs @@ -86,7 +86,7 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { /// <https://html.spec.whatwg.org/multipage/#event-loop-processing-model:fully-active> fn store_task_for_inactive_pipeline(&self, msg: T, pipeline_id: &PipelineId) { let mut inactive = self.inactive.borrow_mut(); - let inactive_queue = inactive.entry(pipeline_id.clone()).or_default(); + let inactive_queue = inactive.entry(*pipeline_id).or_default(); inactive_queue.push_back( msg.into_queued_task() .expect("Incoming messages should always be convertible into queued tasks"), @@ -152,7 +152,7 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { } } // Immediately send non-throttled tasks for processing. - let _ = self.msg_queue.borrow_mut().push_back(msg); + self.msg_queue.borrow_mut().push_back(msg); } for msg in to_be_throttled { @@ -237,16 +237,16 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { // Reduce the length of throttles, // but don't add the task to "msg_queue", // and neither increment "taken_task_counter". - throttled_length = throttled_length - 1; + throttled_length -= 1; continue; } } // Make the task available for the event-loop to handle as a message. - let _ = self.msg_queue.borrow_mut().push_back(msg); + self.msg_queue.borrow_mut().push_back(msg); self.taken_task_counter .set(self.taken_task_counter.get() + 1); - throttled_length = throttled_length - 1; + throttled_length -= 1; }, } } diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index 64c2b3a33c6..9672986b384 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -22,7 +22,7 @@ pub struct DOMManipulationTaskSource(pub Box<dyn ScriptChan + Send>, #[no_trace] impl Clone for DOMManipulationTaskSource { fn clone(&self) -> DOMManipulationTaskSource { - DOMManipulationTaskSource(self.0.clone(), self.1.clone()) + DOMManipulationTaskSource(self.0.clone(), self.1) } } diff --git a/components/script/task_source/file_reading.rs b/components/script/task_source/file_reading.rs index ebf37249b59..77e566dbf63 100644 --- a/components/script/task_source/file_reading.rs +++ b/components/script/task_source/file_reading.rs @@ -18,7 +18,7 @@ pub struct FileReadingTaskSource( impl Clone for FileReadingTaskSource { fn clone(&self) -> FileReadingTaskSource { - FileReadingTaskSource(self.0.clone(), self.1.clone()) + FileReadingTaskSource(self.0.clone(), self.1) } } diff --git a/components/script/task_source/gamepad.rs b/components/script/task_source/gamepad.rs index 5adf519a5e8..e6694f3daea 100644 --- a/components/script/task_source/gamepad.rs +++ b/components/script/task_source/gamepad.rs @@ -19,7 +19,7 @@ pub struct GamepadTaskSource( impl Clone for GamepadTaskSource { fn clone(&self) -> GamepadTaskSource { - GamepadTaskSource(self.0.clone(), self.1.clone()) + GamepadTaskSource(self.0.clone(), self.1) } } diff --git a/components/script/task_source/networking.rs b/components/script/task_source/networking.rs index b95e20aa9fe..b55331af526 100644 --- a/components/script/task_source/networking.rs +++ b/components/script/task_source/networking.rs @@ -16,7 +16,7 @@ pub struct NetworkingTaskSource( impl Clone for NetworkingTaskSource { fn clone(&self) -> NetworkingTaskSource { - NetworkingTaskSource(self.0.clone(), self.1.clone()) + NetworkingTaskSource(self.0.clone(), self.1) } } diff --git a/components/script/task_source/performance_timeline.rs b/components/script/task_source/performance_timeline.rs index b66f1c496b8..9f6f56a2cf4 100644 --- a/components/script/task_source/performance_timeline.rs +++ b/components/script/task_source/performance_timeline.rs @@ -25,7 +25,7 @@ pub struct PerformanceTimelineTaskSource( impl Clone for PerformanceTimelineTaskSource { fn clone(&self) -> PerformanceTimelineTaskSource { - PerformanceTimelineTaskSource(self.0.clone(), self.1.clone()) + PerformanceTimelineTaskSource(self.0.clone(), self.1) } } diff --git a/components/script/task_source/port_message.rs b/components/script/task_source/port_message.rs index 30fe007cbf4..b9bca1e6194 100644 --- a/components/script/task_source/port_message.rs +++ b/components/script/task_source/port_message.rs @@ -18,7 +18,7 @@ pub struct PortMessageQueue( impl Clone for PortMessageQueue { fn clone(&self) -> PortMessageQueue { - PortMessageQueue(self.0.clone(), self.1.clone()) + PortMessageQueue(self.0.clone(), self.1) } } diff --git a/components/script/task_source/remote_event.rs b/components/script/task_source/remote_event.rs index 061558af6c9..cadba9b3016 100644 --- a/components/script/task_source/remote_event.rs +++ b/components/script/task_source/remote_event.rs @@ -16,7 +16,7 @@ pub struct RemoteEventTaskSource( impl Clone for RemoteEventTaskSource { fn clone(&self) -> RemoteEventTaskSource { - RemoteEventTaskSource(self.0.clone(), self.1.clone()) + RemoteEventTaskSource(self.0.clone(), self.1) } } diff --git a/components/script/task_source/timer.rs b/components/script/task_source/timer.rs index 856e05921f4..e565a3aaa22 100644 --- a/components/script/task_source/timer.rs +++ b/components/script/task_source/timer.rs @@ -19,7 +19,7 @@ pub struct TimerTaskSource( impl Clone for TimerTaskSource { fn clone(&self) -> TimerTaskSource { - TimerTaskSource(self.0.clone(), self.1.clone()) + TimerTaskSource(self.0.clone(), self.1) } } diff --git a/components/script/task_source/websocket.rs b/components/script/task_source/websocket.rs index ec5e263fe09..27ad5202373 100644 --- a/components/script/task_source/websocket.rs +++ b/components/script/task_source/websocket.rs @@ -16,7 +16,7 @@ pub struct WebsocketTaskSource( impl Clone for WebsocketTaskSource { fn clone(&self) -> WebsocketTaskSource { - WebsocketTaskSource(self.0.clone(), self.1.clone()) + WebsocketTaskSource(self.0.clone(), self.1) } } |