Skip to content

Commit

Permalink
Simplify check_stack implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Jul 10, 2019
1 parent cd2d832 commit 55a6a76
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/libsyntax/print/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,26 +452,26 @@ impl Printer {
}
}

fn check_stack(&mut self, k: isize) {
fn check_stack(&mut self, k: usize) {
if !self.scan_stack.is_empty() {
let x = self.scan_top();
match self.buf[x].token {
Token::Begin(_) => {
if k > 0 {
let popped = self.scan_pop();
self.buf[popped].size = self.buf[x].size + self.right_total;
self.scan_pop();
self.buf[x].size += self.right_total;
self.check_stack(k - 1);
}
}
Token::End => {
// paper says + not =, but that makes no sense.
let popped = self.scan_pop();
self.buf[popped].size = 1;
self.scan_pop();
self.buf[x].size = 1;
self.check_stack(k + 1);
}
_ => {
let popped = self.scan_pop();
self.buf[popped].size = self.buf[x].size + self.right_total;
self.scan_pop();
self.buf[x].size += self.right_total;
if k > 0 {
self.check_stack(k);
}
Expand Down

0 comments on commit 55a6a76

Please sign in to comment.