Skip to content

Commit 465b513

Browse files
authored
cleanup (#23)
1 parent fd0f02a commit 465b513

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

src/hex/helpers.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,15 @@ fn is_urn_uuid(py_str: &[u8]) -> bool {
7878
#[expect(clippy::inline_always)]
7979
#[inline(always)]
8080
pub fn parse_uuid_hex_str(mut py_str: &[u8], hi: &mut u64, lo: &mut u64) -> c_int {
81-
match py_str.len() {
82-
32 => return parse_hex32(py_str, hi, lo),
83-
36 => return parse_dashed(py_str, hi, lo),
84-
_ => {}
85-
}
81+
let len = py_str.len();
8682

87-
if py_str.len() >= 9 && is_urn_uuid(py_str) {
83+
if len >= 9 && is_urn_uuid(py_str) {
8884
py_str = &py_str[9..];
8985
}
90-
91-
if py_str.len() >= 2 && py_str[0] == b'{' && py_str[py_str.len() - 1] == b'}' {
92-
py_str = &py_str[1..py_str.len() - 1];
86+
if len >= 2 && py_str[0] == b'{' && py_str[len - 1] == b'}' {
87+
py_str = &py_str[1..len - 1];
9388
}
94-
95-
match py_str.len() {
89+
match len {
9690
32 => parse_hex32(py_str, hi, lo),
9791
36 => parse_dashed(py_str, hi, lo),
9892
_ => -1,

src/hex/table.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const HEX_DIGITS: &[u8; 16] = b"0123456789abcdef";
2-
31
#[expect(clippy::large_stack_arrays, clippy::large_stack_frames)]
42
const fn build_hex_words() -> [u32; 65536] {
5-
let mut tmp = [0u32; 65536];
6-
let mut i = 0usize;
3+
const HEX_DIGITS: &[u8; 16] = b"0123456789abcdef";
4+
5+
let mut tmp = [0; 65536];
6+
let mut i = 0;
77

88
while i < 65536 {
99
tmp[i] = u32::from_ne_bytes([
@@ -29,14 +29,14 @@ const fn hex_nibble(c: u8) -> i8 {
2929

3030
#[expect(clippy::large_stack_arrays)]
3131
const fn build_hex_pairs() -> [i16; 65536] {
32-
let mut tmp = [-1i16; 65536];
33-
let mut hi_c = 0u16;
32+
let mut tmp = [-1_i16; 65536];
33+
let mut hi_c = 0_u16;
3434

3535
while hi_c < 256 {
3636
let hn = hex_nibble(hi_c as u8);
3737

3838
if hn >= 0 {
39-
let mut lo_c = 0u16;
39+
let mut lo_c = 0_u16;
4040

4141
while lo_c < 256 {
4242
let ln = hex_nibble(lo_c as u8);

0 commit comments

Comments
 (0)