Simplify the buffer push done by scan_break

This commit is contained in:
David Tolnay 2022-01-18 19:24:17 -08:00
parent fe5c4eab2d
commit 6e8b06015e
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
2 changed files with 3 additions and 8 deletions

View file

@ -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;
}

View file

@ -41,10 +41,6 @@ impl<T> RingBuffer<T> {
pub fn clear(&mut self) {
self.data.clear();
}
pub fn truncate(&mut self, len: usize) {
self.data.truncate(len);
}
}
impl<T> Index<usize> for RingBuffer<T> {