Skip to content

Commit

Permalink
perf: Use &mut to get better LLVM optimization (-2%)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Jan 12, 2019
1 parent a1383b9 commit 7bd988e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions base/src/pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ pub struct Location {
}

impl Location {
pub fn shift(mut self, ch: u8) -> Location {
pub fn shift(&mut self, ch: u8) {
if ch == b'\n' {
self.line += LineOffset(1);
self.column = Column(1);
} else {
self.column += ColumnOffset(1);
}
self.absolute += ByteOffset(1);
self
}
}

Expand Down
2 changes: 1 addition & 1 deletion parser/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl<'input> Iterator for CharLocations<'input> {
fn next(&mut self) -> Option<(Location, u8)> {
self.chars.next().map(|ch| {
let location = self.location;
self.location = self.location.shift(ch);
self.location.shift(ch);
// HACK: The layout algorithm expects `1` indexing for columns -
// this could be altered in the future though
if self.location.column == Column::from(0) {
Expand Down

0 comments on commit 7bd988e

Please sign in to comment.