Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix clippy errors #224

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading