Parcourir la source

Use Iterator::ne to avoid a string allocation.

Simon Sapin il y a 10 ans
Parent
commit
0bd0dcf09d
1 fichiers modifiés avec 1 ajouts et 2 suppressions
  1. 1 2
      src/idna.rs

+ 1 - 2
src/idna.rs

@@ -191,8 +191,7 @@ fn passes_bidi(label: &str, transitional_processing: bool) -> bool {
 
 
 /// http://www.unicode.org/reports/tr46/#Validity_Criteria
 /// http://www.unicode.org/reports/tr46/#Validity_Criteria
 fn validate(label: &str, flags: Uts46Flags) -> Result<(), Error> {
 fn validate(label: &str, flags: Uts46Flags) -> Result<(), Error> {
-    let normalized: String = label.nfc().collect();
-    if normalized != label {
+    if label.nfc().ne(label.chars()) {
         return Err(Error::ValidityCriteria);
         return Err(Error::ValidityCriteria);
     }
     }