mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
serialize: speed up json pretty printing by batch writing spaces
This commit is contained in:
parent
717de500ee
commit
67c8a8d5dd
@ -299,11 +299,20 @@ fn escape_char(writer: &mut io::Writer, v: char) -> Result<(), io::IoError> {
|
||||
escape_bytes(writer, buf)
|
||||
}
|
||||
|
||||
fn spaces(writer: &mut io::Writer, n: uint) -> Result<(), io::IoError> {
|
||||
for _ in range(0, n) {
|
||||
try!(writer.write_str(" "));
|
||||
fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
|
||||
static len: uint = 16;
|
||||
static buf: [u8, ..len] = [b' ', ..len];
|
||||
|
||||
while n >= len {
|
||||
try!(wr.write(buf));
|
||||
n -= len;
|
||||
}
|
||||
|
||||
if n > 0 {
|
||||
wr.write(buf.slice_to(n))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn fmt_number_or_null(v: f64) -> String {
|
||||
|
Loading…
Reference in New Issue
Block a user