fn parse_line(
    line: &str,
    strip_hex: bool,
    stripped_fractional_samples: &mut bool,
) -> Option<(String, usize)> {
    let samplesi = line.rfind(' ')?;
    let mut samples = line[samplesi + 1..].trim_end();

    // Strip fractional part (if any);
    // foobar 1.klwdjlakdj
    //
    // The Perl version keeps the fractional part but inferno
    // strips them in its flamegraph implementation anyway.
    if let Some(doti) = samples.find('.') {
        if !samples[..doti]
            .chars()
            .chain(samples[doti + 1..].chars())
            .all(|c| c.is_digit(10))
        {
            return None;
        }
        // Warn if we're stripping a non-zero fractional part, but only the first time.
        if !*stripped_fractional_samples && !samples[doti + 1..].chars().all(|c| c == '0') {
            *stripped_fractional_samples = true;
            warn!("The input data has fractional sample counts that will be truncated to integers");
        }
        samples = &samples[..doti];
    }

    let nsamples = samples.parse::<usize>().ok()?;
    let stack = line[..samplesi].trim_end();
    if strip_hex {
        Some((strip_hex_address(stack), nsamples))
    } else {
        Some((stack.to_string(), nsamples))
    }
}
// Parse stack and sample count from line.
Parse stack and sample count from line.
Parse stack and sample count from line .
fn parse_line(
    line: &str,
    strip_hex: bool,
    stripped_fractional_samples: &mut bool,
) -> Option<(String, usize)> {
    let samplesi = line.rfind(' ')?;
    let mut samples = line[samplesi + 1..].trim_end();
    // Strip fractional part (if any);
    // foobar 1.klwdjlakdj
    //
    // The Perl version keeps the fractional part but inferno
    // strips them in its flamegraph implementation anyway.
    if let Some(doti) = samples.find('.') {
        if !samples[..doti]
            .chars()
            .chain(samples[doti + 1..].chars())
            .all(|c| c.is_digit(10))
        {
            return None;
        }
        // Warn if we're stripping a non-zero fractional part, but only the first time.
        if !*stripped_fractional_samples && !samples[doti + 1..].chars().all(|c| c == '0') {
            *stripped_fractional_samples = true;
            warn!("The input data has fractional sample counts that will be truncated to integers");
        }
        samples = &samples[..doti];
    }
    let nsamples = samples.parse::<usize>().ok()?;
    let stack = line[..samplesi].trim_end();
    if strip_hex {
        Some((strip_hex_address(stack), nsamples))
    } else {
        Some((stack.to_string(), nsamples))
    }
}
fn parse_line ( line : & str , strip_hex : bool , stripped_fractional_samples : & mut bool , ) -> Option < ( String , usize ) > { let samplesi = line . rfind ( ' ' ) ? ; let mut samples = line [ samplesi + 1 .. ] . trim_end ( ) ; // Strip fractional part (if any); // foobar 1.klwdjlakdj // // The Perl version keeps the fractional part but inferno // strips them in its flamegraph implementation anyway. if let Some ( doti ) = samples . find ( '.' ) { if ! samples [ .. doti ] . chars ( ) . chain ( samples [ doti + 1 .. ] . chars ( ) ) . all ( | c | c . is_digit ( 10 ) ) { return None ; } // Warn if we're stripping a non-zero fractional part, but only the first time. if ! * stripped_fractional_samples && ! samples [ doti + 1 .. ] . chars ( ) . all ( | c | c == '0' ) { * stripped_fractional_samples = true ; warn ! ( " " ) ; } samples = & samples [ .. doti ] ; } let nsamples = samples . parse :: < usize > ( ) . ok ( ) ? ; let stack = line [ .. samplesi ] . trim_end ( ) ; if strip_hex { Some ( ( strip_hex_address ( stack ) , nsamples ) ) } else { Some ( ( stack . to_string ( ) , nsamples ) ) } }
Parse stack and sample count from line.
Parse stack and sample count from line .
line
&str
strip_hex
bool
stripped_fractional_samples
&mut bool
line
&str
strip_hex
bool
stripped_fractional_samples
&mut bool