Skip to content

Commit

Permalink
Move BufEntry assignment into scan_push
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Jul 10, 2019
1 parent ccf279d commit cd2d832
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/libsyntax/print/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,7 @@ impl Printer {
}
debug!("pp Begin({})/buffer Vec<{},{}>",
b.offset, self.left, self.right);
self.buf[self.right] = BufEntry { token: Token::Begin(b), size: -self.right_total };
let right = self.right;
self.scan_push(right);
self.scan_push(BufEntry { token: Token::Begin(b), size: -self.right_total });
}

fn pretty_print_end(&mut self) {
Expand All @@ -340,9 +338,7 @@ impl Printer {
} else {
debug!("pp End/buffer Vec<{},{}>", self.left, self.right);
self.advance_right();
self.buf[self.right] = BufEntry { token: Token::End, size: -1 };
let right = self.right;
self.scan_push(right);
self.scan_push(BufEntry { token: Token::End, size: -1 });
}
}

Expand All @@ -358,9 +354,7 @@ impl Printer {
debug!("pp Break({})/buffer Vec<{},{}>",
b.offset, self.left, self.right);
self.check_stack(0);
let right = self.right;
self.scan_push(right);
self.buf[self.right] = BufEntry { token: Token::Break(b), size: -self.right_total };
self.scan_push(BufEntry { token: Token::Break(b), size: -self.right_total });
self.right_total += b.blank_space;
}

Expand Down Expand Up @@ -397,9 +391,10 @@ impl Printer {
}
}

fn scan_push(&mut self, x: usize) {
debug!("scan_push {}", x);
self.scan_stack.push_front(x);
fn scan_push(&mut self, entry: BufEntry) {
debug!("scan_push {}", self.right);
self.buf[self.right] = entry;
self.scan_stack.push_front(self.right);
}

fn scan_pop(&mut self) -> usize {
Expand Down

0 comments on commit cd2d832

Please sign in to comment.