Skip to content

Conversation

@sylvestre
Copy link
Contributor

No description provided.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 30, 2025

CodSpeed Performance Report

Merging #9930 will degrade performance by 3.05%

Comparing sylvestre:expand-cognitive_complexity (14e2b56) with main (77c3498)

Summary

❌ 1 regression
✅ 135 untouched
⏩ 6 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Efficiency
expand_custom_tabstops[50000] 36.9 ms 38 ms -3.05%

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sylvestre sylvestre force-pushed the expand-cognitive_complexity branch from 969f0e0 to 14e2b56 Compare December 30, 2025 21:49
///
/// Returns `(CharType, display_width, byte_length)`.
#[inline]
fn classify_char(buf: &[u8], byte: usize, uflag: bool) -> (CharType, usize, usize) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a more descriptive name than uflag. Or alternatively, split the function into two functions so you don't need uflag.

fn classify_char(buf: &[u8], byte: usize, uflag: bool) -> (CharType, usize, usize) {
use self::CharType::{Backspace, Other, Tab};

if uflag {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm misunderstanding the meaning of uflag, but shouldn't the if and else blocks be switched? From the help:

-U, --no-utf8         interpret input file as 8-bit ASCII rather than UTF-8

Currently, the code does the opposite: if uflag is true, the char is handled as UTF-8.

Comment on lines +369 to +370
Some('\t') => (Tab, 0, nbytes),
Some('\x08') => (Backspace, 0, nbytes),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct that the display_width for Tab and Backspace differs between UTF-8 and ASCII?

Comment on lines +369 to +370
Some('\t') => (Tab, 0, nbytes),
Some('\x08') => (Backspace, 0, nbytes),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use the concrete byte length instead of nbytes:

Suggested change
Some('\t') => (Tab, 0, nbytes),
Some('\x08') => (Backspace, 0, nbytes),
Some('\t') => (Tab, 0, 1),
Some('\x08') => (Backspace, 0, 1),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants