Browse Source

Use Iterator::ne to avoid a string allocation.

Simon Sapin 10 năm trước cách đây
mục cha
commit
0bd0dcf09d
1 tập tin đã thay đổi với 1 bổ sung2 xóa
  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);
     }