From fdb95f54e81532f5a620e79b8930f89e0e9aee80 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 18 Jan 2022 19:02:49 -0800 Subject: [PATCH] Inline Printer's advance_right method --- compiler/rustc_ast_pretty/src/pp.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs index 25437f8b53a..785125ccafc 100644 --- a/compiler/rustc_ast_pretty/src/pp.rs +++ b/compiler/rustc_ast_pretty/src/pp.rs @@ -290,7 +290,8 @@ fn scan_begin(&mut self, b: BeginToken) { self.right = self.left; self.buf.truncate(1); } else { - self.advance_right(); + self.right += 1; + self.buf.advance_right(); } self.scan_push(BufEntry { token: Token::Begin(b), size: -self.right_total }); } @@ -299,7 +300,8 @@ fn scan_end(&mut self) { if self.scan_stack.is_empty() { self.print_end(); } else { - self.advance_right(); + self.right += 1; + self.buf.advance_right(); self.scan_push(BufEntry { token: Token::End, size: -1 }); } } @@ -311,7 +313,8 @@ fn scan_break(&mut self, b: BreakToken) { self.right = self.left; self.buf.truncate(1); } else { - self.advance_right(); + self.right += 1; + self.buf.advance_right(); } self.check_stack(0); self.scan_push(BufEntry { token: Token::Break(b), size: -self.right_total }); @@ -322,7 +325,8 @@ fn scan_string(&mut self, s: Cow<'static, str>) { if self.scan_stack.is_empty() { self.print_string(s); } else { - self.advance_right(); + self.right += 1; + self.buf.advance_right(); let len = s.len() as isize; self.buf[self.right] = BufEntry { token: Token::String(s), size: len }; self.right_total += len; @@ -360,11 +364,6 @@ fn scan_pop_bottom(&mut self) -> usize { self.scan_stack.pop_back().unwrap() } - fn advance_right(&mut self) { - self.right += 1; - self.buf.advance_right(); - } - fn advance_left(&mut self) { let mut left_size = self.buf[self.left].size;