Skip to content

Commit

Permalink
Simplify scan_break
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 7, 2022
1 parent c2d5b63 commit bb85c61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,15 @@ impl Printer {
self.left_total = 1;
self.right_total = 1;
self.right = self.left;
self.buf.truncate(1);
self.buf.clear();
} else {
self.check_stack(0);
self.right += 1;
self.buf.advance_right();
}
self.check_stack(0);
self.buf[self.right] = BufEntry {
self.buf.push(BufEntry {
token: Token::Break(b),
size: -self.right_total,
};
});
self.scan_stack.push_back(self.right);
self.right_total += b.blank_space;
}
Expand Down
4 changes: 0 additions & 4 deletions src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,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> {
Expand Down

0 comments on commit bb85c61

Please sign in to comment.