Skip to content

Commit 0091e6e

Browse files
Stop relying on io::Write
1 parent 48fd838 commit 0091e6e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/libsyntax/print/pp.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
137137
use std::collections::VecDeque;
138138
use std::fmt;
139-
use std::io::{self, Write};
139+
use std::io;
140140
use std::borrow::Cow;
141141
use log::debug;
142142

@@ -497,10 +497,10 @@ impl<'a> Printer<'a> {
497497

498498
crate fn print_newline(&mut self, amount: isize) -> io::Result<()> {
499499
debug!("NEWLINE {}", amount);
500-
let ret = write!(self.out, "\n");
500+
self.out.push(b'\n');
501501
self.pending_indentation = 0;
502502
self.indent(amount);
503-
ret
503+
Ok(())
504504
}
505505

506506
crate fn indent(&mut self, amount: isize) {
@@ -592,15 +592,17 @@ impl<'a> Printer<'a> {
592592
// difference is significant on some workloads.
593593
let spaces_len = SPACES.len() as isize;
594594
while self.pending_indentation >= spaces_len {
595-
self.out.write_all(&SPACES)?;
595+
self.out.extend_from_slice(&SPACES);
596596
self.pending_indentation -= spaces_len;
597597
}
598598
if self.pending_indentation > 0 {
599-
self.out.write_all(&SPACES[0..self.pending_indentation as usize])?;
599+
self.out.extend_from_slice(&SPACES[0..self.pending_indentation as usize]);
600600
self.pending_indentation = 0;
601601
}
602602

603-
write!(self.out, "{}", s)
603+
self.out.extend_from_slice(s.as_bytes());
604+
605+
Ok(())
604606
}
605607

606608
crate fn print(&mut self, token: Token, l: isize) -> io::Result<()> {

0 commit comments

Comments
 (0)