Skip to content
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 azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ jobs:
- template: default.yml@templates
parameters:
codecov_token: $(CODECOV_TOKEN_SECRET)
minrust: 1.46.0
minrust: 1.52.0
env:
RUST_BACKTRACE: 1
setup:
Expand Down
2 changes: 1 addition & 1 deletion src/bin/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl<'a> Opt {
#[cfg(feature = "nameattr")]
fn set_func_frameattrs(&self, options: &mut Options) {
if let Some(file) = &self.nameattr {
match FuncFrameAttrsMap::from_file(&file) {
match FuncFrameAttrsMap::from_file(file) {
Ok(m) => {
options.func_frameattrs = m;
}
Expand Down
6 changes: 2 additions & 4 deletions src/collapse/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,13 @@ fn with_module_fallback(module: &str, func: &str, pc: &str, include_addrs: bool)
// output string is a bit longer than rawfunc but not much
let mut res = String::with_capacity(func.len() + 12);

res.push('[');
res.push_str(func);
if include_addrs {
res.push('[');
res.push_str(func);
res.push_str(" <");
res.push_str(pc);
res.push_str(">]");
} else {
res.push('[');
res.push_str(func);
res.push(']');
}

Expand Down
4 changes: 2 additions & 2 deletions src/collapse/vtune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ impl From<Options> for Folder {

impl Folder {
fn line_parts<'a>(&self, line: &'a str) -> Option<(&'a str, &'a str, &'a str)> {
let mut line = if line.starts_with('"') {
let mut line = if let Some(line) = line.strip_prefix('"') {
// The function name will be in quotes if it contains spaces.
line[1..].splitn(2, "\",")
line.splitn(2, "\",")
} else {
// We split on a string because we need to match the type of the other if branch.
#[allow(clippy::single_char_pattern)]
Expand Down
8 changes: 4 additions & 4 deletions src/flamegraph/attrs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::path::PathBuf;
use std::path::Path;

use ahash::AHashMap;
use indexmap::map::Entry;
Expand All @@ -27,7 +27,7 @@ impl FuncFrameAttrsMap {
///
/// Each line should consist of a function name, a tab (`\t`), and then a sequence of
/// tab-separated `name=value` pairs.
pub fn from_file(path: &PathBuf) -> io::Result<FuncFrameAttrsMap> {
pub fn from_file(path: &Path) -> io::Result<FuncFrameAttrsMap> {
let file = BufReader::new(File::open(path)?);
FuncFrameAttrsMap::from_reader(file)
}
Expand Down Expand Up @@ -158,8 +158,8 @@ impl<'a> Iterator for AttrIter<'a> {
warn!("no value after \"=\" for extra attribute {}", name);
}

let (value, rest) = if rest.starts_with('"') {
if let Some(eq) = rest[1..].find('"') {
let (value, rest) = if let Some(stripped_rest) = rest.strip_prefix('"') {
if let Some(eq) = stripped_rest.find('"') {
(&rest[1..=eq], &rest[eq + 1..])
} else {
warn!("no end quote found for extra attribute {}", name);
Expand Down
6 changes: 1 addition & 5 deletions src/flamegraph/color/palettes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ pub(super) mod java {
}
}

let java_prefix = if name.starts_with('L') {
&name[1..]
} else {
name
};
let java_prefix = name.strip_prefix('L').unwrap_or(name);

if name.contains("::") || name.starts_with("-[") || name.starts_with("+[") {
// C++ or Objective C
Expand Down
16 changes: 8 additions & 8 deletions src/flamegraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ where
error!("No stack counts found");
// emit an error message SVG, for tools automating flamegraph use
let imageheight = opt.font_size * 5;
svg::write_header(&mut svg, imageheight, &opt)?;
svg::write_header(&mut svg, imageheight, opt)?;
svg::write_str(
&mut svg,
&mut buffer,
Expand Down Expand Up @@ -493,7 +493,7 @@ where

// draw canvas, and embed interactive JavaScript program
let imageheight = ((depthmax + 1) * opt.frame_height) + opt.ypad1() + opt.ypad2();
svg::write_header(&mut svg, imageheight, &opt)?;
svg::write_header(&mut svg, imageheight, opt)?;

let (bgcolor1, bgcolor2) = color::bgcolor_for(opt.bgcolors, opt.colors);
let style_options = StyleOptions {
Expand All @@ -502,7 +502,7 @@ where
bgcolor2,
};

svg::write_prelude(&mut svg, &style_options, &opt)?;
svg::write_prelude(&mut svg, &style_options, opt)?;

// Used when picking color parameters at random, when no option determines how to pick these
// parameters. We instanciate it here because it may be called once for each iteration in the
Expand Down Expand Up @@ -573,7 +573,7 @@ where
write!(buffer, "all ({} {}, 100%)", samples_txt, opt.count_name)
} else {
let pct = (100 * samples) as f64 / (timemax as f64 * opt.factor);
let function = deannotate(&frame.location.function);
let function = deannotate(frame.location.function);
match frame.delta {
None => write!(
buffer,
Expand Down Expand Up @@ -634,7 +634,7 @@ where
let colors = opt.colors;
let hash = opt.hash;
let deterministic = opt.deterministic;
palette_map.find_color_for(&frame.location.function, |name| {
palette_map.find_color_for(frame.location.function, |name| {
color::color(colors, hash, deterministic, name, &mut thread_rng)
})
} else {
Expand All @@ -653,7 +653,7 @@ where
.trunc() as usize;
let text: svg::TextArgument<'_> = if fitchars >= 3 {
// room for one char plus two dots
let f = deannotate(&frame.location.function);
let f = deannotate(frame.location.function);

// TODO: use Unicode grapheme clusters instead
if f.len() < fitchars {
Expand Down Expand Up @@ -718,11 +718,11 @@ fn write_container_start<'a, W: Write>(
let mut has_href = false;
if let Some(frame_attributes) = frame_attributes {
if frame_attributes.attrs.contains_key("xlink:href") {
write_container_attributes(cache_a, &frame_attributes);
write_container_attributes(cache_a, frame_attributes);
svg.write_event(&cache_a)?;
has_href = true;
} else {
write_container_attributes(cache_g, &frame_attributes);
write_container_attributes(cache_g, frame_attributes);
svg.write_event(&cache_g)?;
}
if let Some(ref t) = frame_attributes.title {
Expand Down