Skip to content

Commit 483f247

Browse files
committed
perf: gate PartialEq derive to test builds only
The PartialEq derive was being compiled into release builds even though it's only used in test code. This caused a 3.33% performance regression in the du_human_balanced_tree benchmark due to increased binary size affecting CPU cache efficiency. Changes: - stty.rs: Gate PartialEq derive on Flag<T> with #[cfg_attr(test, derive(PartialEq))] - flags.rs: Gate PartialEq derive on AllFlags enum with #[cfg_attr(test, derive(PartialEq))] This eliminates the performance regression while keeping all test code functional and unchanged.
1 parent 670b14b commit 483f247

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/uu/stty/src/flags.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ use nix::sys::termios::{
2727
SpecialCharacterIndices as S,
2828
};
2929

30-
#[derive(Debug, PartialEq)]
30+
#[derive(Debug)]
31+
#[cfg_attr(test, derive(PartialEq))]
3132
pub enum AllFlags<'a> {
3233
#[cfg(any(
3334
target_os = "freebsd",

src/uu/stty/src/stty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ const SANE_CONTROL_CHARS: [(S, u8); 12] = [
6363
(S::VDISCARD, 15), // ^O
6464
];
6565

66-
#[derive(Clone, Copy, Debug, PartialEq)]
66+
#[derive(Clone, Copy, Debug)]
67+
#[cfg_attr(test, derive(PartialEq))]
6768
pub struct Flag<T> {
6869
name: &'static str,
6970
#[expect(clippy::struct_field_names)]

0 commit comments

Comments
 (0)