Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = ["cpu-features"]
name = "json-escape-simd"
version = "3.0.0"
edition = "2024"
rust-version = "1.89.0"
rust-version = "1.85.0"
include = ["src/**/*.rs"]
description = "Optimized SIMD routines for escaping JSON strings."
license = "MIT"
Expand All @@ -18,6 +18,7 @@ path = "examples/escape.rs"

[features]
codspeed = ["criterion2/codspeed"]
avx512 = []
asan = [] # for ASAN

[[bench]]
Expand Down
10 changes: 7 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,13 @@ fn format_string(value: &str, dst: &mut [u8]) -> usize {

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
if is_x86_feature_detected!("avx512f") {
unsafe { simd::avx512::format_string(value, dst) }
} else if is_x86_feature_detected!("avx2") {
#[cfg(feature = "avx512")]
{
if is_x86_feature_detected!("avx512f") {
return unsafe { simd::avx512::format_string(value, dst) };
}
}
if is_x86_feature_detected!("avx2") {
unsafe { simd::avx2::format_string(value, dst) }
} else if is_x86_feature_detected!("sse2") {
unsafe { simd::sse2::format_string(value, dst) }
Expand Down
2 changes: 1 addition & 1 deletion src/simd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
pub(crate) mod avx2;
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
#[cfg(all(any(target_arch = "x86_64", target_arch = "x86"), feature = "avx512"))]
pub(crate) mod avx512;
pub mod bits;
#[cfg(target_arch = "aarch64")]
Expand Down
Loading