File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ pub fn to_ascii(domain: &str) -> Result<Cow<str>, IdnaError> {
1818
1919 // Fast path: check if the whole domain is valid ASCII and doesn't need transformation
2020 let mut label_start = 0 ;
21- let mut all_ascii = true ;
2221 let mut needs_alloc = false ;
2322 let bytes = domain. as_bytes ( ) ;
2423 let mut i = 0 ;
@@ -29,12 +28,10 @@ pub fn to_ascii(domain: &str) -> Result<Cow<str>, IdnaError> {
2928 return Err ( IdnaError :: EmptyLabel ) ;
3029 }
3130 match process_label_to_ascii ( label) ? {
32- Cow :: Borrowed ( _) => { } ,
31+ Cow :: Borrowed ( _) => { }
3332 Cow :: Owned ( _) => needs_alloc = true ,
3433 }
3534 label_start = i + 1 ;
36- } else if bytes[ i] >= 128 {
37- all_ascii = false ;
3835 }
3936 i += 1 ;
4037 }
@@ -102,7 +99,7 @@ fn process_label_to_ascii(label: &str) -> Result<Cow<str>, IdnaError> {
10299 all_lower = false ;
103100 break ;
104101 }
105- if !( b'a' ..= b'z' ) . contains ( & b ) && !( b'0' ..= b'9' ) . contains ( & b ) && b != b'-' {
102+ if !b . is_ascii_lowercase ( ) && !b . is_ascii_digit ( ) && b != b'-' {
106103 // Not lowercase ASCII, digit, or hyphen
107104 all_lower = false ;
108105 break ;
You can’t perform that action at this time.
0 commit comments