mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-28 16:07:57 +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<()> {
|
||||
for _ in range(0, n) {
|
||||
try!(wr.write_str(" "));
|
||||
fn spaces<W: Writer>(wr: &mut W, mut n: uint) -> IoResult<()> {
|
||||
static len: uint = 16;
|
||||
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)]
|
||||
|
||||
Reference in New Issue
Block a user