Skip to content

Commit d540b78

Browse files
committed
chore: hide avx512 behind feature flag
1 parent 6054ef0 commit d540b78

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ members = ["cpu-features"]
55
name = "json-escape-simd"
66
version = "3.0.0"
77
edition = "2024"
8-
rust-version = "1.89.0"
8+
rust-version = "1.85.0"
99
include = ["src/**/*.rs"]
1010
description = "Optimized SIMD routines for escaping JSON strings."
1111
license = "MIT"
@@ -18,6 +18,7 @@ path = "examples/escape.rs"
1818

1919
[features]
2020
codspeed = ["criterion2/codspeed"]
21+
avx512 = []
2122
asan = [] # for ASAN
2223

2324
[[bench]]

src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,13 @@ fn format_string(value: &str, dst: &mut [u8]) -> usize {
297297

298298
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
299299
{
300-
if is_x86_feature_detected!("avx512f") {
301-
unsafe { simd::avx512::format_string(value, dst) }
302-
} else if is_x86_feature_detected!("avx2") {
300+
#[cfg(feature = "avx512")]
301+
{
302+
if is_x86_feature_detected!("avx512f") {
303+
return unsafe { simd::avx512::format_string(value, dst) };
304+
}
305+
}
306+
if is_x86_feature_detected!("avx2") {
303307
unsafe { simd::avx2::format_string(value, dst) }
304308
} else if is_x86_feature_detected!("sse2") {
305309
unsafe { simd::sse2::format_string(value, dst) }

src/simd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
44
pub(crate) mod avx2;
5-
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
5+
#[cfg(all(any(target_arch = "x86_64", target_arch = "x86"), feature = "avx512"))]
66
pub(crate) mod avx512;
77
pub mod bits;
88
#[cfg(target_arch = "aarch64")]

0 commit comments

Comments
 (0)