Skip to content

Commit 702dc15

Browse files
committed
Improve get_arch_ops() usage
1 parent 3af5cdb commit 702dc15

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ use digest::{DynDigest, InvalidBufferSize};
151151
use std::fs::File;
152152
#[cfg(feature = "std")]
153153
use std::io::{Read, Write};
154+
use crate::feature_detection::get_arch_ops;
154155

155156
mod algorithm;
156157
mod arch;
@@ -820,8 +821,6 @@ pub fn checksum_combine_with_params(
820821
/// // "x86_64-sse-pclmulqdq" - x86_64 baseline with SSE4.1 and PCLMULQDQ
821822
/// ```
822823
pub fn get_calculator_target(_algorithm: CrcAlgorithm) -> String {
823-
use crate::feature_detection::get_arch_ops;
824-
825824
let arch_ops = get_arch_ops();
826825
arch_ops.get_target_string()
827826
}
@@ -864,12 +863,11 @@ fn get_calculator_params(algorithm: CrcAlgorithm) -> (CalculatorFn, CrcParams) {
864863
/// fusion techniques to accelerate the calculation beyond what SIMD can do alone.
865864
#[inline(always)]
866865
fn crc32_iscsi_calculator(state: u64, data: &[u8], _params: CrcParams) -> u64 {
867-
use crate::feature_detection::get_arch_ops;
868-
let arch_ops = get_arch_ops();
869-
870866
#[cfg(target_arch = "aarch64")]
871867
{
872868
use crate::feature_detection::PerformanceTier;
869+
870+
let arch_ops = get_arch_ops();
873871
match arch_ops.get_tier() {
874872
PerformanceTier::AArch64AesSha3 | PerformanceTier::AArch64Aes => {
875873
return fusion::crc32_iscsi(state as u32, data) as u64;
@@ -881,6 +879,8 @@ fn crc32_iscsi_calculator(state: u64, data: &[u8], _params: CrcParams) -> u64 {
881879
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
882880
{
883881
use crate::feature_detection::PerformanceTier;
882+
883+
let arch_ops = get_arch_ops();
884884
match arch_ops.get_tier() {
885885
PerformanceTier::X86_64Avx512Vpclmulqdq
886886
| PerformanceTier::X86_64Avx512Pclmulqdq

0 commit comments

Comments
 (0)