Skip to content

Commit

Permalink
chore: Fix clippy errors (#224)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Lamb <andrew@nerdnetworks.org>
  • Loading branch information
alamb authored Sep 26, 2023
1 parent 1deed8c commit 92f4a12
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct Bucket<T: 'static> {

impl<T: Eq + Default> Default for Bucket<T> {
fn default() -> Bucket<T> {
let entries = Box::new(Default::default());
let entries = Box::default();

Self { length: 0, entries }
}
Expand Down
28 changes: 14 additions & 14 deletions src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ pub struct Profiler {

running: bool,

#[cfg(all(any(
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
))]
blocklist_segments: Vec<(usize, usize)>,
}

#[derive(Clone)]
pub struct ProfilerGuardBuilder {
frequency: c_int,
#[cfg(all(any(
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
))]
blocklist_segments: Vec<(usize, usize)>,
}

Expand All @@ -60,12 +60,12 @@ impl Default for ProfilerGuardBuilder {
ProfilerGuardBuilder {
frequency: 99,

#[cfg(all(any(
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
))]
blocklist_segments: Vec::new(),
}
}
Expand All @@ -76,12 +76,12 @@ impl ProfilerGuardBuilder {
Self { frequency, ..self }
}

#[cfg(all(any(
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
))]
pub fn blocklist<T: AsRef<str>>(self, blocklist: &[T]) -> Self {
let blocklist_segments = {
let mut segments = Vec::new();
Expand Down Expand Up @@ -126,12 +126,12 @@ impl ProfilerGuardBuilder {
Err(Error::CreatingError)
}
Ok(profiler) => {
#[cfg(all(any(
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
))]
{
profiler.blocklist_segments = self.blocklist_segments;
}
Expand Down Expand Up @@ -388,22 +388,22 @@ impl Profiler {
sample_counter: 0,
running: false,

#[cfg(all(any(
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
))]
blocklist_segments: Vec::new(),
})
}

#[cfg(all(any(
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
))]
fn is_blocklisted(&self, addr: usize) -> bool {
for libs in &self.blocklist_segments {
if addr > libs.0 && addr < libs.1 {
Expand Down
2 changes: 1 addition & 1 deletion src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mod protobuf {
/// `pprof` will generate google's pprof format report.
pub fn pprof(&self) -> crate::Result<protos::Profile> {
let mut dedup_str = HashSet::new();
for key in self.data.iter().map(|(key, _)| key) {
for key in self.data.keys() {
dedup_str.insert(key.thread_name_or_id());
for frame in key.frames.iter() {
for symbol in frame {
Expand Down

0 comments on commit 92f4a12

Please sign in to comment.