@@ -751,10 +751,6 @@ 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;
758
754
759
755
/**
760
756
* A dummy trait to hold all the utility methods that we implement on strings.
@@ -2070,14 +2066,13 @@ impl OwnedStr for ~str {
2070
2066
/// Appends a character to the back of a string
2071
2067
#[inline]
2072
2068
fn push_char(&mut self, c: char) {
2069
+ assert!(c as uint <= 0x10ffff); // FIXME: #7609: should be enforced on all `char`
2073
2070
unsafe {
2074
2071
let code = c as uint;
2075
2072
let nb = if code < MAX_ONE_B { 1u }
2076
2073
else if code < MAX_TWO_B { 2u }
2077
2074
else if code < MAX_THREE_B { 3u }
2078
- else if code < MAX_FOUR_B { 4u }
2079
- else if code < MAX_FIVE_B { 5u }
2080
- else { 6u };
2075
+ else { 4u };
2081
2076
let len = self.len();
2082
2077
let new_len = len + nb;
2083
2078
self.reserve_at_least(new_len);
@@ -2103,21 +2098,6 @@ impl OwnedStr for ~str {
2103
2098
*ptr::mut_offset(buf, off + 2u) = (code >> 6u & 63u | TAG_CONT) as u8;
2104
2099
*ptr::mut_offset(buf, off + 3u) = (code & 63u | TAG_CONT) as u8;
2105
2100
}
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
- }
2121
2101
_ => {}
2122
2102
}
2123
2103
}
0 commit comments