Skip to content

Commit

Permalink
Fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed May 7, 2024
1 parent 783fee8 commit 069764a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ impl Config {
}

config.subprocesses = matches.occurrences_of("subprocesses") > 0;
config.command = subcommand.to_owned();
subcommand.clone_into(&mut config.command);

// options that can be shared between subcommands
config.pid = matches
Expand Down Expand Up @@ -639,14 +639,14 @@ mod tests {
);

// test out overriding these params by setting flags
assert_eq!(config.include_idle, false);
assert_eq!(config.gil_only, false);
assert_eq!(config.include_thread_ids, false);
assert!(!config.include_idle);
assert!(!config.gil_only);
assert!(!config.include_thread_ids);

let config_flags = get_config("py-spy r -p 1234 -o foo --idle --gil --threads").unwrap();
assert_eq!(config_flags.include_idle, true);
assert_eq!(config_flags.gil_only, true);
assert_eq!(config_flags.include_thread_ids, true);
assert!(config_flags.include_idle);
assert!(config_flags.gil_only);
assert!(config_flags.include_thread_ids);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/coredump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ mod test {
// we won't have the python binary for the core dump here,
// so we can't (yet) figure out the interpreter address & version.
// Manually specify here to test out instead
let core = CoreDump::new(&get_coredump_path("python_3_9_threads")).unwrap();
let core = CoreDump::new(get_coredump_path("python_3_9_threads")).unwrap();
let version = Version {
major: 3,
minor: 9,
Expand Down
2 changes: 1 addition & 1 deletion src/cython.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl SourceMaps {
if let Some(map) = self.maps.get(&frame.filename) {
if let Some(map) = map {
if let Some((file, line)) = map.lookup(line) {
frame.filename = file.clone();
frame.filename.clone_from(file);
frame.line = *line as i32;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ fn sample_pyroscope(pid: remoteprocess::Pid, config: &Config) -> Result<(), Erro
});
}

if let Some(process_info) = trace.process_info.as_ref().map(|x| x) {
if let Some(process_info) = trace.process_info.as_ref() {
trace.frames.push(process_info.to_frame());
let mut parent = process_info.parent.as_ref();
while parent.is_some() {
Expand All @@ -446,7 +446,7 @@ fn sample_pyroscope(pid: remoteprocess::Pid, config: &Config) -> Result<(), Erro
}

samples += 1;
output.increment(&trace)?;
output.increment(trace)?;
}

send_samples += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/python_data_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ pub mod tests {
};
unsafe {
let ptr = &mut ret as *mut AllocatedPyASCIIObject as *mut u8;
let dst = ptr.offset(std::mem::size_of::<PyASCIIObject>() as isize);
let dst = ptr.add(std::mem::size_of::<PyASCIIObject>());
copy_nonoverlapping(bytes.as_ptr(), dst, bytes.len());
}
ret
Expand Down
6 changes: 3 additions & 3 deletions src/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Sampler {
spy
}
Err(e) => {
if initialized_tx.send(Err(e)).is_err() {}
initialized_tx.send(Err(e)).is_err();
return;
}
};
Expand Down Expand Up @@ -219,7 +219,7 @@ impl Sampler {
let process = process_info
.entry(pid)
.or_insert_with(|| get_process_info(pid, &spies).map(|p| Arc::new(*p)));
trace.process_info = process.clone();
trace.process_info.clone_from(process);
}

// Send the collected info back
Expand Down Expand Up @@ -308,7 +308,7 @@ impl PythonSpyThread {
}
Err(e) => {
warn!("Failed to profile python from process {}: {}", pid, e);
if initialized_tx.send(Err(e)).is_err() {}
initialized_tx.send(Err(e)).is_err();
return;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/speedscope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl Stats {

self.samples
.entry(key)
.or_insert_with(std::vec::Vec::new)
.or_default()
.push(frame_indices);
let subprocesses = self.config.subprocesses;
self.thread_name_map.entry(key).or_insert_with(|| {
Expand Down
1 change: 0 additions & 1 deletion src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::time::{Duration, Instant};
#[cfg(windows)]
use winapi::um::timeapi;

use rand;
use rand_distr::{Distribution, Exp};

/// Timer is an iterator that sleeps an appropriate amount of time between iterations
Expand Down

0 comments on commit 069764a

Please sign in to comment.