mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-14 23:11:01 +00:00
write spaces in batches
This commit is contained in:
@@ -792,11 +792,20 @@ 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)]
|
||||||
|
|||||||
Reference in New Issue
Block a user