Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor(wc): use uucore's SIMD policy instead of local cpu_features
- Add "hardware" feature to uucore dependency in Cargo.toml
- Replace local cpu_features module with uucore::hardware::simd_policy
- Update debug output to use enabled_features() method for consistency
  • Loading branch information
mattsu2020 committed Nov 24, 2025
commit a7400a66125de946db7415bd8a04dd63bc81db66
2 changes: 1 addition & 1 deletion src/uu/wc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ path = "src/wc.rs"

[dependencies]
clap = { workspace = true }
uucore = { workspace = true, features = ["parser", "pipes", "quoting-style"] }
uucore = { workspace = true, features = ["parser", "pipes", "quoting-style", "hardware"] }
bytecount = { workspace = true, features = ["runtime-dispatch-simd"] }
thiserror = { workspace = true }
unicode-width = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions src/uu/wc/src/count_fast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
// file that was distributed with this source code.

// cSpell:ignore sysconf
use crate::{cpu_features, word_count::WordCount};
use crate::word_count::WordCount;
use uucore::hardware::simd_policy;

use super::WordCountable;

Expand Down Expand Up @@ -232,7 +233,7 @@ pub(crate) fn count_bytes_chars_and_lines_fast<
) -> (WordCount, Option<io::Error>) {
let mut total = WordCount::default();
let buf: &mut [u8] = &mut AlignedBuffer::default().data;
let simd_allowed = cpu_features::simd_policy().env_allows_simd();
let simd_allowed = simd_policy().allows_simd();
loop {
match handle.read(buf) {
Ok(0) => return (total, None),
Expand Down
99 changes: 0 additions & 99 deletions src/uu/wc/src/cpu_features.rs

This file was deleted.

12 changes: 6 additions & 6 deletions src/uu/wc/src/wc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

mod count_fast;
mod countable;
mod cpu_features;
mod utf8;
mod word_count;

Expand All @@ -28,6 +27,7 @@ use utf8::{BufReadDecoder, BufReadDecoderError};
use uucore::translate;

use uucore::{
hardware::simd_policy,
error::{FromIo, UError, UResult},
format_usage,
parser::shortcut_value_parser::ShortcutValueParser,
Expand Down Expand Up @@ -827,15 +827,15 @@ fn wc(inputs: &Inputs, settings: &Settings) -> UResult<()> {
};

if settings.debug {
let policy = cpu_features::simd_policy();
if policy.env_allows_simd() {
let available = policy.available_features();
if available.is_empty() {
let policy = simd_policy();
if policy.allows_simd() {
let enabled = policy.enabled_features();
if enabled.is_empty() {
eprintln!("wc: debug: hardware support unavailable on this CPU");
Copy link
Contributor

Choose a reason for hiding this comment

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

please use the translate! macro

} else {
eprintln!(
"wc: debug: using hardware support (features: {})",
available.join(", ")
enabled.join(", ")
);
}
} else {
Expand Down
Loading