mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-22 20:53:37 +00:00
Index a single time in check_stack
This commit is contained in:
parent
a37d272892
commit
377c9dbabf
@ -380,24 +380,25 @@ impl Printer {
|
||||
|
||||
fn check_stack(&mut self, mut k: usize) {
|
||||
while let Some(&x) = self.scan_stack.front() {
|
||||
match self.buf[x].token {
|
||||
let mut entry = &mut self.buf[x];
|
||||
match entry.token {
|
||||
Token::Begin(_) => {
|
||||
if k == 0 {
|
||||
break;
|
||||
}
|
||||
self.scan_stack.pop_front().unwrap();
|
||||
self.buf[x].size += self.right_total;
|
||||
entry.size += self.right_total;
|
||||
k -= 1;
|
||||
}
|
||||
Token::End => {
|
||||
// paper says + not =, but that makes no sense.
|
||||
self.scan_stack.pop_front().unwrap();
|
||||
self.buf[x].size = 1;
|
||||
entry.size = 1;
|
||||
k += 1;
|
||||
}
|
||||
_ => {
|
||||
self.scan_stack.pop_front().unwrap();
|
||||
self.buf[x].size += self.right_total;
|
||||
entry.size += self.right_total;
|
||||
if k == 0 {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user