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