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:
Marvin Löbel
2014-08-14 01:02:31 +02:00
parent 78ec3904b4
commit 13079c1a85
7 changed files with 47 additions and 42 deletions

View File

@@ -1110,7 +1110,7 @@ pub trait Writer {
#[inline]
fn write_char(&mut self, c: char) -> IoResult<()> {
let mut buf = [0u8, ..4];
let n = c.encode_utf8(buf.as_mut_slice());
let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
self.write(buf.slice_to(n))
}