Optimized IR generation for UTF-8 and UTF-16 encoding
- Both can now be inlined and constant folded away - Both can no longer cause failure - Both now return an `Option` instead Removed debug `assert!()`s over the valid ranges of a `char` - It affected optimizations due to unwinding - Char handling is now sound enought that they became uneccessary
This commit is contained in:
@@ -173,7 +173,7 @@ fn test_escape_unicode() {
|
||||
fn test_encode_utf8() {
|
||||
fn check(input: char, expect: &[u8]) {
|
||||
let mut buf = [0u8, ..4];
|
||||
let n = input.encode_utf8(buf /* as mut slice! */);
|
||||
let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
|
||||
assert_eq!(buf.slice_to(n), expect);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ fn test_encode_utf8() {
|
||||
fn test_encode_utf16() {
|
||||
fn check(input: char, expect: &[u16]) {
|
||||
let mut buf = [0u16, ..2];
|
||||
let n = input.encode_utf16(buf /* as mut slice! */);
|
||||
let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
|
||||
assert_eq!(buf.slice_to(n), expect);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user