File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
compiler/rustc_ast_pretty/src Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ mod ring;
137137use ring:: RingBuffer ;
138138use std:: borrow:: Cow ;
139139use std:: collections:: VecDeque ;
140+ use std:: iter;
140141
141142/// How to break. Described in more detail in the module docs.
142143#[ derive( Clone , Copy , PartialEq ) ]
@@ -425,20 +426,18 @@ impl Printer {
425426 }
426427
427428 fn print_string ( & mut self , string : & str ) {
428- let len = string. len ( ) as isize ;
429- // assert!(len <= space);
430- self . space -= len;
431-
432429 // Write the pending indent. A more concise way of doing this would be:
433430 //
434431 // write!(self.out, "{: >n$}", "", n = self.pending_indentation as usize)?;
435432 //
436433 // But that is significantly slower. This code is sufficiently hot, and indents can get
437434 // sufficiently large, that the difference is significant on some workloads.
438435 self . out . reserve ( self . pending_indentation as usize ) ;
439- self . out . extend ( std :: iter:: repeat ( ' ' ) . take ( self . pending_indentation as usize ) ) ;
436+ self . out . extend ( iter:: repeat ( ' ' ) . take ( self . pending_indentation as usize ) ) ;
440437 self . pending_indentation = 0 ;
438+
441439 self . out . push_str ( string) ;
440+ self . space -= string. len ( ) as isize ;
442441 }
443442
444443 // Convenience functions to talk to the printer.
You can’t perform that action at this time.
0 commit comments