Skip to content

Commit

Permalink
Fix aarch64 stable build
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Aug 20, 2021
1 parent 669e4a2 commit 707db98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pyo3 = { version = "^0.14.2", default_features = false, features = ["extension-m
ryu = { version = "1", default_features = false }
serde = { version = "1", default_features = false }
serde_json = { version = "^1.0.66", default_features = false, features = ["std", "float_roundtrip"] }
simdutf8 = { version = "0.1", default_features = false, optional = true }
simdutf8 = { version = "0.1", default_features = false, features = ["std"] }
smallvec = { version = "^1.6", default_features = false, features = ["union", "write"] }

[profile.release]
Expand Down
12 changes: 6 additions & 6 deletions src/deserialize/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::fmt;
use std::os::raw::c_char;
use std::ptr::NonNull;

#[cfg(all(target_arch = "x86_64", feature = "unstable-simd"))]
#[cfg(target_arch = "x86_64")]
fn is_valid_utf8(buf: &[u8]) -> bool {
if std::is_x86_feature_detected!("sse4.2") {
simdutf8::basic::from_utf8(buf).is_ok()
Expand All @@ -22,19 +22,19 @@ fn is_valid_utf8(buf: &[u8]) -> bool {
}
}

#[cfg(all(target_arch = "x86_64", not(feature = "unstable-simd")))]
#[cfg(all(target_arch = "aarch64", feature = "unstable-simd"))]
fn is_valid_utf8(buf: &[u8]) -> bool {
encoding_rs::Encoding::utf8_valid_up_to(buf) == buf.len()
simdutf8::basic::from_utf8(buf).is_ok()
}

#[cfg(target_arch = "aarch64")]
#[cfg(all(target_arch = "aarch64", not(feature = "unstable-simd")))]
fn is_valid_utf8(buf: &[u8]) -> bool {
simdutf8::basic::from_utf8(buf).is_ok()
std::str::from_utf8(buf).is_ok()
}

#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
fn is_valid_utf8(buf: &[u8]) -> bool {
simdutf8::basic::from_utf8(buf).is_ok()
std::str::from_utf8(buf).is_ok()
}

pub fn deserialize(
Expand Down

0 comments on commit 707db98

Please sign in to comment.