Eliminate a token clone from advance_left
This commit is contained in:
parent
d81740ed2a
commit
d981c5b354
@ -319,7 +319,7 @@ fn advance_left(&mut self) {
|
||||
let mut left_size = self.buf.first().unwrap().size;
|
||||
|
||||
while left_size >= 0 {
|
||||
let left = self.buf.first().unwrap().token.clone();
|
||||
let left = self.buf.pop_first().unwrap().token;
|
||||
|
||||
let len = match left {
|
||||
Token::Break(b) => b.blank_space,
|
||||
@ -335,7 +335,6 @@ fn advance_left(&mut self) {
|
||||
|
||||
self.left_total += len;
|
||||
|
||||
self.buf.advance_left();
|
||||
if self.buf.is_empty() {
|
||||
break;
|
||||
}
|
||||
|
@ -32,11 +32,6 @@ pub fn push(&mut self, value: T) -> usize {
|
||||
index
|
||||
}
|
||||
|
||||
pub fn advance_left(&mut self) {
|
||||
self.data.pop_front().unwrap();
|
||||
self.offset += 1;
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.data.clear();
|
||||
}
|
||||
@ -53,6 +48,12 @@ pub fn first_mut(&mut self) -> Option<&mut T> {
|
||||
self.data.front_mut()
|
||||
}
|
||||
|
||||
pub fn pop_first(&mut self) -> Option<T> {
|
||||
let first = self.data.pop_front()?;
|
||||
self.offset += 1;
|
||||
Some(first)
|
||||
}
|
||||
|
||||
pub fn last(&self) -> Option<&T> {
|
||||
self.data.back()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user