Merge pull request #71 from lifthrasiir/json-split-branch

Replace a redundant `escape` variable with nested matches.
This commit is contained in:
Erick Tryzelaar 2015-05-07 10:51:57 -07:00
commit af752ddcb5

View File

@ -307,15 +307,23 @@ impl<Iter> Deserializer<Iter>
fn parse_string(&mut self) -> Result<(), Error> {
self.str_buf.clear();
let mut escape = false;
loop {
let ch = match try!(self.next_char()) {
Some(ch) => ch,
None => { return Err(self.error(ErrorCode::EOFWhileParsingString)); }
};
if escape {
match ch {
b'"' => {
try!(self.bump());
return Ok(());
}
b'\\' => {
let ch = match try!(self.next_char()) {
Some(ch) => ch,
None => { return Err(self.error(ErrorCode::EOFWhileParsingString)); }
};
match ch {
b'"' => self.str_buf.push(b'"'),
b'\\' => self.str_buf.push(b'\\'),
@ -377,15 +385,6 @@ impl<Iter> Deserializer<Iter>
return Err(self.error(ErrorCode::InvalidEscape));
}
}
escape = false;
} else {
match ch {
b'"' => {
try!(self.bump());
return Ok(());
}
b'\\' => {
escape = true;
}
ch => {
self.str_buf.push(ch);
@ -393,7 +392,6 @@ impl<Iter> Deserializer<Iter>
}
}
}
}
fn parse_object_colon(&mut self) -> Result<(), Error> {
try!(self.parse_whitespace());