write spaces in batches
This commit is contained in:
parent
c83d38ce79
commit
076a35075a
15
json.rs
15
json.rs
@ -792,12 +792,21 @@ fn fmt_f64_or_null<W: Writer>(wr: &mut W, v: f64) -> IoResult<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spaces<W: Writer>(wr: &mut W, n: uint) -> IoResult<()> {
|
fn spaces<W: Writer>(wr: &mut W, mut n: uint) -> IoResult<()> {
|
||||||
for _ in range(0, n) {
|
static len: uint = 16;
|
||||||
try!(wr.write_str(" "));
|
static buf: [u8, ..len] = [b' ', ..len];
|
||||||
|
|
||||||
|
while n >= buf.len() {
|
||||||
|
try!(wr.write(buf));
|
||||||
|
n -= buf.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if n > 0 {
|
||||||
|
wr.write(buf.slice_to(n))
|
||||||
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[deriving(Show)]
|
#[deriving(Show)]
|
||||||
enum SerializerState {
|
enum SerializerState {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user