mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
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
This commit is contained in:
parent
3651b650c4
commit
058319aa0b
12 changed files with 18 additions and 19 deletions
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue