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;
137
137
use ring:: RingBuffer ;
138
138
use std:: borrow:: Cow ;
139
139
use std:: collections:: VecDeque ;
140
+ use std:: iter;
140
141
141
142
/// How to break. Described in more detail in the module docs.
142
143
#[ derive( Clone , Copy , PartialEq ) ]
@@ -425,20 +426,18 @@ impl Printer {
425
426
}
426
427
427
428
fn print_string ( & mut self , string : & str ) {
428
- let len = string. len ( ) as isize ;
429
- // assert!(len <= space);
430
- self . space -= len;
431
-
432
429
// Write the pending indent. A more concise way of doing this would be:
433
430
//
434
431
// write!(self.out, "{: >n$}", "", n = self.pending_indentation as usize)?;
435
432
//
436
433
// But that is significantly slower. This code is sufficiently hot, and indents can get
437
434
// sufficiently large, that the difference is significant on some workloads.
438
435
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 ) ) ;
440
437
self . pending_indentation = 0 ;
438
+
441
439
self . out . push_str ( string) ;
440
+ self . space -= string. len ( ) as isize ;
442
441
}
443
442
444
443
// Convenience functions to talk to the printer.
You can’t perform that action at this time.
0 commit comments