mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
clippy: fix warnings in various modules in components (#31568)
* clippy: fix warnings in various modules in components * fix: unit tests * fix: build on android * fix: all samplers use new_boxed
This commit is contained in:
parent
19f1f2a8f4
commit
3a5ca785d3
24 changed files with 107 additions and 118 deletions
|
@ -30,8 +30,8 @@ pub struct Profiler {
|
|||
created: Instant,
|
||||
}
|
||||
|
||||
const JEMALLOC_HEAP_ALLOCATED_STR: &'static str = "jemalloc-heap-allocated";
|
||||
const SYSTEM_HEAP_ALLOCATED_STR: &'static str = "system-heap-allocated";
|
||||
const JEMALLOC_HEAP_ALLOCATED_STR: &str = "jemalloc-heap-allocated";
|
||||
const SYSTEM_HEAP_ALLOCATED_STR: &str = "system-heap-allocated";
|
||||
|
||||
impl Profiler {
|
||||
pub fn create(period: Option<f64>) -> ProfilerChan {
|
||||
|
@ -84,7 +84,7 @@ impl Profiler {
|
|||
|
||||
pub fn new(port: IpcReceiver<ProfilerMsg>) -> Profiler {
|
||||
Profiler {
|
||||
port: port,
|
||||
port,
|
||||
reporters: HashMap::new(),
|
||||
created: Instant::now(),
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ impl Profiler {
|
|||
|
||||
println!("|");
|
||||
println!("End memory reports");
|
||||
println!("");
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ impl ReportsTree {
|
|||
ReportsTree {
|
||||
size: 0,
|
||||
count: 0,
|
||||
path_seg: path_seg,
|
||||
path_seg,
|
||||
children: vec![],
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ impl ReportsTree {
|
|||
fn insert(&mut self, path: &[String], size: usize) {
|
||||
let mut t: &mut ReportsTree = self;
|
||||
for path_seg in path {
|
||||
let i = match t.find_child(&path_seg) {
|
||||
let i = match t.find_child(path_seg) {
|
||||
Some(i) => i,
|
||||
None => {
|
||||
let new_t = ReportsTree::new(path_seg.clone());
|
||||
|
@ -352,7 +352,7 @@ impl ReportsForest {
|
|||
|
||||
fn print(&mut self) {
|
||||
// Fill in sizes of interior nodes, and recursively sort the sub-trees.
|
||||
for (_, tree) in &mut self.trees {
|
||||
for tree in self.trees.values_mut() {
|
||||
tree.compute_interior_node_sizes_and_sort();
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ impl ReportsForest {
|
|||
// single node) come after non-degenerate trees. Secondary sort: alphabetical order of the
|
||||
// root node's path_seg.
|
||||
let mut v = vec![];
|
||||
for (_, tree) in &self.trees {
|
||||
for tree in self.trees.values() {
|
||||
v.push(tree);
|
||||
}
|
||||
v.sort_by(|a, b| {
|
||||
|
@ -412,9 +412,9 @@ mod system_reporter {
|
|||
let mut report = |path, size| {
|
||||
if let Some(size) = size {
|
||||
reports.push(Report {
|
||||
path: path,
|
||||
path,
|
||||
kind: ReportKind::NonExplicitSize,
|
||||
size: size,
|
||||
size,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -663,7 +663,7 @@ mod system_reporter {
|
|||
|
||||
// Construct the segment name from its pathname and permissions.
|
||||
curr_seg_name.clear();
|
||||
if pathname == "" || pathname.starts_with("[stack:") {
|
||||
if pathname.is_empty() || pathname.starts_with("[stack:") {
|
||||
// Anonymous memory. Entries marked with "[stack:nnn]"
|
||||
// look like thread stacks but they may include other
|
||||
// anonymous mappings, so we can't trust them and just
|
||||
|
@ -674,7 +674,7 @@ mod system_reporter {
|
|||
}
|
||||
curr_seg_name.push_str(" (");
|
||||
curr_seg_name.push_str(perms);
|
||||
curr_seg_name.push_str(")");
|
||||
curr_seg_name.push(')');
|
||||
|
||||
looking_for = LookingFor::Rss;
|
||||
} else {
|
||||
|
|
|
@ -184,9 +184,9 @@ impl Profiler {
|
|||
})
|
||||
.expect("Thread spawning failed");
|
||||
// decide if we need to spawn the timer thread
|
||||
match option {
|
||||
&OutputOptions::FileName(_) => { /* no timer thread needed */ },
|
||||
&OutputOptions::Stdout(period) => {
|
||||
match *option {
|
||||
OutputOptions::FileName(_) => { /* no timer thread needed */ },
|
||||
OutputOptions::Stdout(period) => {
|
||||
// Spawn a timer thread
|
||||
let chan = chan.clone();
|
||||
thread::Builder::new()
|
||||
|
@ -241,11 +241,11 @@ impl Profiler {
|
|||
output: Option<OutputOptions>,
|
||||
) -> Profiler {
|
||||
Profiler {
|
||||
port: port,
|
||||
port,
|
||||
buckets: BTreeMap::new(),
|
||||
output: output,
|
||||
output,
|
||||
last_msg: None,
|
||||
trace: trace,
|
||||
trace,
|
||||
blocked_layout_queries: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ impl Profiler {
|
|||
}
|
||||
|
||||
fn find_or_insert(&mut self, k: (ProfilerCategory, Option<TimerMetadata>), t: f64) {
|
||||
self.buckets.entry(k).or_insert_with(Vec::new).push(t);
|
||||
self.buckets.entry(k).or_default().push(t);
|
||||
}
|
||||
|
||||
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
||||
|
@ -321,24 +321,24 @@ impl Profiler {
|
|||
match self.output {
|
||||
Some(OutputOptions::FileName(ref filename)) => {
|
||||
let path = Path::new(&filename);
|
||||
let mut file = match File::create(&path) {
|
||||
let mut file = match File::create(path) {
|
||||
Err(e) => panic!("Couldn't create {}: {}", path.display(), e),
|
||||
Ok(file) => file,
|
||||
};
|
||||
write!(
|
||||
writeln!(
|
||||
file,
|
||||
"_category_\t_incremental?_\t_iframe?_\t_url_\t_mean (ms)_\t\
|
||||
_median (ms)_\t_min (ms)_\t_max (ms)_\t_events_\n"
|
||||
_median (ms)_\t_min (ms)_\t_max (ms)_\t_events_"
|
||||
)
|
||||
.unwrap();
|
||||
for (&(ref category, ref meta), ref mut data) in &mut self.buckets {
|
||||
for ((category, meta), ref mut data) in &mut self.buckets {
|
||||
data.sort_by(|a, b| a.partial_cmp(b).expect("No NaN values in profiles"));
|
||||
let data_len = data.len();
|
||||
if data_len > 0 {
|
||||
let (mean, median, min, max) = Self::get_statistics(data);
|
||||
write!(
|
||||
writeln!(
|
||||
file,
|
||||
"{}\t{}\t{:15.4}\t{:15.4}\t{:15.4}\t{:15.4}\t{:15}\n",
|
||||
"{}\t{}\t{:15.4}\t{:15.4}\t{:15.4}\t{:15.4}\t{:15}",
|
||||
category.format(&self.output),
|
||||
meta.format(&self.output),
|
||||
mean,
|
||||
|
@ -351,9 +351,9 @@ impl Profiler {
|
|||
}
|
||||
}
|
||||
|
||||
write!(file, "_url\t_blocked layout queries_\n").unwrap();
|
||||
writeln!(file, "_url\t_blocked layout queries_").unwrap();
|
||||
for (url, count) in &self.blocked_layout_queries {
|
||||
write!(file, "{}\t{}\n", url, count).unwrap();
|
||||
writeln!(file, "{}\t{}", url, count).unwrap();
|
||||
}
|
||||
},
|
||||
Some(OutputOptions::Stdout(_)) => {
|
||||
|
@ -374,7 +374,7 @@ impl Profiler {
|
|||
" _events_"
|
||||
)
|
||||
.unwrap();
|
||||
for (&(ref category, ref meta), ref mut data) in &mut self.buckets {
|
||||
for ((category, meta), ref mut data) in &mut self.buckets {
|
||||
data.sort_by(|a, b| a.partial_cmp(b).expect("No NaN values in profiles"));
|
||||
let data_len = data.len();
|
||||
if data_len > 0 {
|
||||
|
@ -393,13 +393,13 @@ impl Profiler {
|
|||
.unwrap();
|
||||
}
|
||||
}
|
||||
writeln!(&mut lock, "").unwrap();
|
||||
writeln!(&mut lock).unwrap();
|
||||
|
||||
writeln!(&mut lock, "_url_\t_blocked layout queries_").unwrap();
|
||||
for (url, count) in &self.blocked_layout_queries {
|
||||
writeln!(&mut lock, "{}\t{}", url, count).unwrap();
|
||||
}
|
||||
writeln!(&mut lock, "").unwrap();
|
||||
writeln!(&mut lock).unwrap();
|
||||
},
|
||||
None => { /* Do nothing if no output option has been set */ },
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ impl TraceDump {
|
|||
{
|
||||
let mut file = fs::File::create(trace_file_path)?;
|
||||
write_prologue(&mut file)?;
|
||||
Ok(TraceDump { file: file })
|
||||
Ok(TraceDump { file })
|
||||
}
|
||||
|
||||
/// Write one trace to the trace dump file.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue