|
136 | 136 |
|
137 | 137 | use std::collections::VecDeque; |
138 | 138 | use std::fmt; |
139 | | -use std::io::{self, Write}; |
| 139 | +use std::io; |
140 | 140 | use std::borrow::Cow; |
141 | 141 | use log::debug; |
142 | 142 |
|
@@ -497,10 +497,10 @@ impl<'a> Printer<'a> { |
497 | 497 |
|
498 | 498 | crate fn print_newline(&mut self, amount: isize) -> io::Result<()> { |
499 | 499 | debug!("NEWLINE {}", amount); |
500 | | - let ret = write!(self.out, "\n"); |
| 500 | + self.out.push(b'\n'); |
501 | 501 | self.pending_indentation = 0; |
502 | 502 | self.indent(amount); |
503 | | - ret |
| 503 | + Ok(()) |
504 | 504 | } |
505 | 505 |
|
506 | 506 | crate fn indent(&mut self, amount: isize) { |
@@ -592,15 +592,17 @@ impl<'a> Printer<'a> { |
592 | 592 | // difference is significant on some workloads. |
593 | 593 | let spaces_len = SPACES.len() as isize; |
594 | 594 | while self.pending_indentation >= spaces_len { |
595 | | - self.out.write_all(&SPACES)?; |
| 595 | + self.out.extend_from_slice(&SPACES); |
596 | 596 | self.pending_indentation -= spaces_len; |
597 | 597 | } |
598 | 598 | 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]); |
600 | 600 | self.pending_indentation = 0; |
601 | 601 | } |
602 | 602 |
|
603 | | - write!(self.out, "{}", s) |
| 603 | + self.out.extend_from_slice(s.as_bytes()); |
| 604 | + |
| 605 | + Ok(()) |
604 | 606 | } |
605 | 607 |
|
606 | 608 | crate fn print(&mut self, token: Token, l: isize) -> io::Result<()> { |
|
0 commit comments