scx_utils::cpumask: Default to displaying in hex

There isn't much to gain by displaying cpumasks in binary. Drop separate
Display implementation just default to 'x' formatting.
This commit is contained in:
Tejun Heo 2024-08-19 23:29:20 -10:00
parent 3ca2f0b6f9
commit 1ae4655b3c

View File

@ -195,19 +195,6 @@ impl Cpumask {
}
}
impl fmt::Display for Cpumask {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let slice = self.as_raw_slice();
let mut remaining_width = *NR_CPU_IDS + 2;
write!(f, "{:#0width$b}", slice[0], width = remaining_width.min(66))?;
for submask in &slice[1..] {
remaining_width -= 64;
write!(f, "{:0width$b}", submask, width = remaining_width.min(64))?;
}
Ok(())
}
}
impl Cpumask {
fn fmt_with(&self, f: &mut fmt::Formatter<'_>, case: char) -> fmt::Result {
let mut masks: Vec<u32> = self
@ -243,6 +230,12 @@ impl Cpumask {
}
}
impl fmt::Display for Cpumask {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.fmt_with(f, 'x')
}
}
impl fmt::LowerHex for Cpumask {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.fmt_with(f, 'x')