Skip to content

Commit f4ad50d

Browse files
committed
Add minor improvements
Suggested by GitHub Copilot on PR review.
1 parent 83e13eb commit f4ad50d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/crc32/fusion/aarch64/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use iso_hdlc::crc_pmull_sha3::crc32_iso_hdlc_eor3_v9s3x2e_s3;
2828
pub fn crc32_iscsi(crc: u32, data: &[u8]) -> u32 {
2929
let data_len = data.len();
3030

31-
// there's some variance among different aarch64 CPUs (Applie Silicon, AWS Graviton, etc), but
31+
// there's some variance among different aarch64 CPUs (Apple Silicon, AWS Graviton, etc.), but
3232
// 127 bytes is the "small" threshold where this is generally faster
3333
if data_len < 128 {
3434
return unsafe { crc32_iscsi_small_fast(crc, data) };
@@ -50,7 +50,7 @@ pub fn crc32_iscsi(crc: u32, data: &[u8]) -> u32 {
5050
pub fn crc32_iso_hdlc(crc: u32, data: &[u8]) -> u32 {
5151
let data_len = data.len();
5252

53-
// there's some variance among different aarch64 CPUs (Applie Silicon, AWS Graviton, etc), but
53+
// there's some variance among different aarch64 CPUs (Apple Silicon, AWS Graviton, etc.), but
5454
// 127 bytes is the "small" threshold where this is generally faster
5555
if data_len < 128 {
5656
return unsafe { crc32_iso_hdlc_small_fast(crc, data) };
@@ -68,7 +68,6 @@ pub fn crc32_iso_hdlc(crc: u32, data: &[u8]) -> u32 {
6868
}
6969
}
7070

71-
/// Safe wrapper for CRC-32/ISCSI calculation with AES + SHA3 support
7271
#[inline]
7372
#[target_feature(enable = "crc,aes,sha3")]
7473
unsafe fn crc32_iscsi_aes_sha3(crc: u32, data: &[u8], data_len: usize) -> u32 {
@@ -90,7 +89,6 @@ unsafe fn crc32_iscsi_aes(crc: u32, data: &[u8], data_len: usize) -> u32 {
9089
unsafe { crc32_iscsi_v12e_v1(crc, data.as_ptr(), data_len) }
9190
}
9291

93-
/// Safe wrapper for CRC32 ISO-HDLC calculation
9492
#[inline]
9593
#[target_feature(enable = "crc,aes,sha3")]
9694
unsafe fn crc32_iso_hdlc_aes_sha3(crc: u32, data: &[u8], data_len: usize) -> u32 {
@@ -148,7 +146,7 @@ unsafe fn clmul_hi_and_xor(a: uint64x2_t, b: uint64x2_t, c: uint64x2_t) -> uint6
148146
veorq_u64(clmul_hi(a, b), c)
149147
}
150148

151-
/// CRC-32/ISCSI calculation for small buffers (<= 96 bytes) using unrolled native CRC instructions
149+
/// CRC-32/ISCSI calculation for small buffers (< 128 bytes) using unrolled native CRC instructions
152150
#[inline]
153151
#[target_feature(enable = "crc")]
154152
pub unsafe fn crc32_iscsi_small_fast(mut crc: u32, data: &[u8]) -> u32 {
@@ -185,7 +183,7 @@ pub unsafe fn crc32_iscsi_small_fast(mut crc: u32, data: &[u8]) -> u32 {
185183
crc
186184
}
187185

188-
/// CRC-32/ISO-HDLC calculation for small buffers (<= 96 bytes) using unrolled native CRC instructions
186+
/// CRC-32/ISO-HDLC calculation for small buffers (< 128 bytes) using unrolled native CRC instructions
189187
#[inline]
190188
#[target_feature(enable = "crc")]
191189
pub unsafe fn crc32_iso_hdlc_small_fast(mut crc: u32, data: &[u8]) -> u32 {

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ pub fn crc32_iscsi(data: &[u8]) -> u32 {
10001000
/// let checksum = crc32_iso_hdlc(b"123456789");
10011001
/// assert_eq!(checksum, 0xcbf43926);
10021002
/// ```
1003+
#[inline(always)]
10031004
pub fn crc32_iso_hdlc(data: &[u8]) -> u32 {
10041005
crc32_iso_hdlc_calculator(CRC32_ISO_HDLC.init, data, &CRC32_ISO_HDLC) as u32
10051006
^ CRC32_ISO_HDLC.xorout as u32
@@ -1019,6 +1020,7 @@ pub fn crc32_iso_hdlc(data: &[u8]) -> u32 {
10191020
/// let checksum = crc64_nvme(b"123456789");
10201021
/// assert_eq!(checksum, 0xae8b14860a799888);
10211022
/// ```
1023+
#[inline(always)]
10221024
pub fn crc64_nvme(data: &[u8]) -> u64 {
10231025
Calculator::calculate(CRC64_NVME.init, data, &CRC64_NVME) ^ CRC64_NVME.xorout
10241026
}

0 commit comments

Comments
 (0)