@@ -220,11 +220,11 @@ impl Wtf8Buf {
220
220
let surrogate = surrogate. unpaired_surrogate ( ) ;
221
221
// Surrogates are known to be in the code point range.
222
222
let code_point = unsafe { CodePoint :: from_u32_unchecked ( surrogate as u32 ) } ;
223
+ // The string will now contain an unpaired surrogate.
224
+ string. is_known_utf8 = false ;
223
225
// Skip the WTF-8 concatenation check,
224
226
// surrogate pairs are already decoded by decode_utf16
225
227
string. push_code_point_unchecked ( code_point) ;
226
- // The string now contains an unpaired surrogate.
227
- string. is_known_utf8 = false ;
228
228
}
229
229
}
230
230
}
@@ -346,13 +346,13 @@ impl Wtf8Buf {
346
346
self . bytes . extend_from_slice ( other_without_trail_surrogate) ;
347
347
}
348
348
_ => {
349
- self . bytes . extend_from_slice ( & other. bytes ) ;
350
-
351
- // If we're pushing a string containing a surrogate, we may no
352
- // longer have UTF-8.
349
+ // If we'll be pushing a string containing a surrogate, we may
350
+ // no longer have UTF-8.
353
351
if other. next_surrogate ( 0 ) . is_some ( ) {
354
352
self . is_known_utf8 = false ;
355
353
}
354
+
355
+ self . bytes . extend_from_slice ( & other. bytes ) ;
356
356
}
357
357
}
358
358
}
@@ -721,8 +721,8 @@ impl Wtf8 {
721
721
}
722
722
723
723
pub fn clone_into ( & self , buf : & mut Wtf8Buf ) {
724
- self . bytes . clone_into ( & mut buf. bytes ) ;
725
724
buf. is_known_utf8 = false ;
725
+ self . bytes . clone_into ( & mut buf. bytes ) ;
726
726
}
727
727
728
728
/// Boxes this `Wtf8`.
0 commit comments