Skip to content

Commit

Permalink
[do not merge] disable escape handling
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jun 24, 2021
1 parent 07a320c commit f7e335c
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions valuable-json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,32 +240,33 @@ impl<W: io::Write> Serializer<W> {
self.start_string()?;

let bytes = s.as_bytes();
self.push_bytes(bytes)?;

let mut start = 0;
// let mut start = 0;

for (i, &byte) in bytes.iter().enumerate() {
let escape = escape(byte, self.option.escape_solidus);
// for (i, &byte) in bytes.iter().enumerate() {
// let escape = escape(byte, self.option.escape_solidus);

if matches!(escape, Escape::None) {
continue;
}
// if matches!(escape, Escape::None) {
// continue;
// }

if start < i {
self.push_bytes(&bytes[start..i])?;
}
// if start < i {
// self.push_bytes(&bytes[start..i])?;
// }

match escape {
Escape::Char(bytes) => self.push_bytes(&bytes)?,
Escape::Control(bytes) => self.push_bytes(&bytes)?,
Escape::None => unreachable!(),
}
// match escape {
// Escape::Char(bytes) => self.push_bytes(&bytes)?,
// Escape::Control(bytes) => self.push_bytes(&bytes)?,
// Escape::None => unreachable!(),
// }

start = i + 1;
}
// start = i + 1;
// }

if start != bytes.len() {
self.push_bytes(&bytes[start..])?;
}
// if start != bytes.len() {
// self.push_bytes(&bytes[start..])?;
// }

self.end_string()
}
Expand Down

0 comments on commit f7e335c

Please sign in to comment.