Skip to content

Commit 0dd0c8a

Browse files
committed
---
yaml --- r: 83957 b: refs/heads/dist-snap c: 51eb1e1 h: refs/heads/master i: 83955: 2871543 v: v3
1 parent b4abd43 commit 0dd0c8a

File tree

3 files changed

+11
-52
lines changed

3 files changed

+11
-52
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 37494d39d38be33a589a1f46dae38fe2ceb9d94f
9+
refs/heads/dist-snap: 51eb1e14d4285f157e9820f5ee61bc150cf554ad
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/json.rs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -481,30 +481,22 @@ pub fn to_pretty_str(json: &Json) -> ~str {
481481
io::with_str_writer(|wr| to_pretty_writer(wr, json))
482482
}
483483

484-
static BUF_SIZE : uint = 64000;
485-
486484
#[allow(missing_doc)]
487485
pub struct Parser {
488486
priv rdr: @io::Reader,
489-
priv buf: ~[char],
490-
priv buf_idx: uint,
491487
priv ch: char,
492488
priv line: uint,
493489
priv col: uint,
494490
}
495491

496492
/// Decode a json value from an io::reader
497493
pub fn Parser(rdr: @io::Reader) -> Parser {
498-
let mut p = Parser {
494+
Parser {
499495
rdr: rdr,
500-
buf: rdr.read_chars(BUF_SIZE),
501-
buf_idx: 0,
502-
ch: 0 as char,
496+
ch: rdr.read_char(),
503497
line: 1,
504-
col: 0,
505-
};
506-
p.bump();
507-
p
498+
col: 1,
499+
}
508500
}
509501

510502
impl Parser {
@@ -529,26 +521,13 @@ impl Parser {
529521
fn eof(&self) -> bool { self.ch == -1 as char }
530522

531523
fn bump(&mut self) {
532-
if self.eof() {
533-
return;
534-
}
535-
536-
self.col += 1u;
537-
538-
if self.buf_idx >= self.buf.len() {
539-
self.buf = self.rdr.read_chars(BUF_SIZE);
540-
if self.buf.len() == 0 {
541-
self.ch = -1 as char;
542-
return;
543-
}
544-
self.buf_idx = 0;
545-
}
546-
self.ch = self.buf[self.buf_idx];
547-
self.buf_idx += 1;
524+
self.ch = self.rdr.read_char();
548525

549526
if self.ch == '\n' {
550527
self.line += 1u;
551528
self.col = 1u;
529+
} else {
530+
self.col += 1u;
552531
}
553532
}
554533

@@ -1744,7 +1723,7 @@ mod tests {
17441723
assert_eq!(v, 0.4e-01f);
17451724
}
17461725
1747-
#[test]
1726+
// FIXME: #7611: xfailed for now
17481727
fn test_read_str() {
17491728
assert_eq!(from_str("\""),
17501729
Err(Error {line: 1u, col: 2u, msg: @~"EOF while parsing string"

branches/dist-snap/src/libstd/str.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,6 @@ static MAX_TWO_B: uint = 2048u;
751751
static TAG_THREE_B: uint = 224u;
752752
static MAX_THREE_B: uint = 65536u;
753753
static TAG_FOUR_B: uint = 240u;
754-
static MAX_FOUR_B: uint = 2097152u;
755-
static TAG_FIVE_B: uint = 248u;
756-
static MAX_FIVE_B: uint = 67108864u;
757-
static TAG_SIX_B: uint = 252u;
758754

759755
/**
760756
* A dummy trait to hold all the utility methods that we implement on strings.
@@ -2070,14 +2066,13 @@ impl OwnedStr for ~str {
20702066
/// Appends a character to the back of a string
20712067
#[inline]
20722068
fn push_char(&mut self, c: char) {
2069+
assert!(c as uint <= 0x10ffff); // FIXME: #7609: should be enforced on all `char`
20732070
unsafe {
20742071
let code = c as uint;
20752072
let nb = if code < MAX_ONE_B { 1u }
20762073
else if code < MAX_TWO_B { 2u }
20772074
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 };
20812076
let len = self.len();
20822077
let new_len = len + nb;
20832078
self.reserve_at_least(new_len);
@@ -2103,21 +2098,6 @@ impl OwnedStr for ~str {
21032098
*ptr::mut_offset(buf, off + 2u) = (code >> 6u & 63u | TAG_CONT) as u8;
21042099
*ptr::mut_offset(buf, off + 3u) = (code & 63u | TAG_CONT) as u8;
21052100
}
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-
}
21212101
_ => {}
21222102
}
21232103
}

0 commit comments

Comments
 (0)