From 6e8b06015e7f0cfa05208c2d83e0a9140f62ab7a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 18 Jan 2022 19:24:17 -0800 Subject: [PATCH] Simplify the buffer push done by scan_break --- compiler/rustc_ast_pretty/src/pp.rs | 7 +++---- compiler/rustc_ast_pretty/src/pp/ring.rs | 4 ---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs index 21e685fff4a..b9b2f77431e 100644 --- a/compiler/rustc_ast_pretty/src/pp.rs +++ b/compiler/rustc_ast_pretty/src/pp.rs @@ -311,13 +311,12 @@ impl Printer { self.left_total = 1; self.right_total = 1; self.right = self.left; - self.buf.truncate(1); + self.buf.clear(); } else { - self.right += 1; - self.buf.advance_right(); self.check_stack(0); + self.right += 1; } - self.buf[self.right] = BufEntry { token: Token::Break(b), size: -self.right_total }; + self.buf.push(BufEntry { token: Token::Break(b), size: -self.right_total }); self.scan_stack.push_front(self.right); self.right_total += b.blank_space; } diff --git a/compiler/rustc_ast_pretty/src/pp/ring.rs b/compiler/rustc_ast_pretty/src/pp/ring.rs index 94bb10382f8..62900ddfa2d 100644 --- a/compiler/rustc_ast_pretty/src/pp/ring.rs +++ b/compiler/rustc_ast_pretty/src/pp/ring.rs @@ -41,10 +41,6 @@ impl RingBuffer { pub fn clear(&mut self) { self.data.clear(); } - - pub fn truncate(&mut self, len: usize) { - self.data.truncate(len); - } } impl Index for RingBuffer {