Răsfoiți Sursa

Use Iterator::ne to avoid a string allocation.

Simon Sapin 10 ani în urmă
părinte
comite
0bd0dcf09d
1 a modificat fișierele cu 1 adăugiri și 2 ștergeri
  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
 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);
     }