@@ -751,6 +751,10 @@ static MAX_TWO_B: uint = 2048u;
751
751
static TAG_THREE_B : uint = 224 u;
752
752
static MAX_THREE_B : uint = 65536 u;
753
753
static TAG_FOUR_B : uint = 240 u;
754
+ static MAX_FOUR_B : uint = 2097152 u;
755
+ static TAG_FIVE_B : uint = 248 u;
756
+ static MAX_FIVE_B : uint = 67108864 u;
757
+ static TAG_SIX_B : uint = 252 u;
754
758
755
759
/**
756
760
* A dummy trait to hold all the utility methods that we implement on strings.
@@ -2066,13 +2070,14 @@ impl OwnedStr for ~str {
2066
2070
/// Appends a character to the back of a string
2067
2071
#[inline]
2068
2072
fn push_char(&mut self, c: char) {
2069
- assert!(c as uint <= 0x10ffff); // FIXME: #7609: should be enforced on all `char`
2070
2073
unsafe {
2071
2074
let code = c as uint;
2072
2075
let nb = if code < MAX_ONE_B { 1u }
2073
2076
else if code < MAX_TWO_B { 2u }
2074
2077
else if code < MAX_THREE_B { 3u }
2075
- else { 4u };
2078
+ else if code < MAX_FOUR_B { 4u }
2079
+ else if code < MAX_FIVE_B { 5u }
2080
+ else { 6u };
2076
2081
let len = self.len();
2077
2082
let new_len = len + nb;
2078
2083
self.reserve_at_least(new_len);
@@ -2098,6 +2103,21 @@ impl OwnedStr for ~str {
2098
2103
*ptr::mut_offset(buf, off + 2u) = (code >> 6u & 63u | TAG_CONT) as u8;
2099
2104
*ptr::mut_offset(buf, off + 3u) = (code & 63u | TAG_CONT) as u8;
2100
2105
}
2106
+ 5u => {
2107
+ *ptr::mut_offset(buf, off) = (code >> 24u & 3u | TAG_FIVE_B) as u8;
2108
+ *ptr::mut_offset(buf, off + 1u) = (code >> 18u & 63u | TAG_CONT) as u8;
2109
+ *ptr::mut_offset(buf, off + 2u) = (code >> 12u & 63u | TAG_CONT) as u8;
2110
+ *ptr::mut_offset(buf, off + 3u) = (code >> 6u & 63u | TAG_CONT) as u8;
2111
+ *ptr::mut_offset(buf, off + 4u) = (code & 63u | TAG_CONT) as u8;
2112
+ }
2113
+ 6u => {
2114
+ *ptr::mut_offset(buf, off) = (code >> 30u & 1u | TAG_SIX_B) as u8;
2115
+ *ptr::mut_offset(buf, off + 1u) = (code >> 24u & 63u | TAG_CONT) as u8;
2116
+ *ptr::mut_offset(buf, off + 2u) = (code >> 18u & 63u | TAG_CONT) as u8;
2117
+ *ptr::mut_offset(buf, off + 3u) = (code >> 12u & 63u | TAG_CONT) as u8;
2118
+ *ptr::mut_offset(buf, off + 4u) = (code >> 6u & 63u | TAG_CONT) as u8;
2119
+ *ptr::mut_offset(buf, off + 5u) = (code & 63u | TAG_CONT) as u8;
2120
+ }
2101
2121
_ => {}
2102
2122
}
2103
2123
}
0 commit comments