Skip to content
Merged
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
8 changes: 4 additions & 4 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn to_ascii(domain: &str) -> Result<Cow<str>, IdnaError> {

// Fast path: check if the whole domain is valid ASCII and doesn't need transformation
let mut label_start = 0;
let mut all_ascii = true;
let mut _all_ascii = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just remove all ascii

let mut needs_alloc = false;
let bytes = domain.as_bytes();
let mut i = 0;
Expand All @@ -29,12 +29,12 @@ pub fn to_ascii(domain: &str) -> Result<Cow<str>, IdnaError> {
return Err(IdnaError::EmptyLabel);
}
match process_label_to_ascii(label)? {
Cow::Borrowed(_) => {},
Cow::Borrowed(_) => {}
Cow::Owned(_) => needs_alloc = true,
}
label_start = i + 1;
} else if bytes[i] >= 128 {
all_ascii = false;
_all_ascii = false;
}
i += 1;
}
Expand Down Expand Up @@ -102,7 +102,7 @@ fn process_label_to_ascii(label: &str) -> Result<Cow<str>, IdnaError> {
all_lower = false;
break;
}
if !(b'a'..=b'z').contains(&b) && !(b'0'..=b'9').contains(&b) && b != b'-' {
if !b.is_ascii_lowercase() && !b.is_ascii_digit() && b != b'-' {
// Not lowercase ASCII, digit, or hyphen
all_lower = false;
break;
Expand Down
Loading