less cloning of the parse state

This commit is contained in:
Folkert 2022-05-14 23:54:15 +02:00
parent 2e3a8befc9
commit dc4f8289ad
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -43,18 +43,18 @@ impl<'a> State<'a> {
}
#[must_use]
pub(crate) fn advance(&self, offset: usize) -> State<'a> {
let mut state = self.clone();
state.offset += offset;
state
#[inline(always)]
pub(crate) const fn advance(mut self, offset: usize) -> State<'a> {
self.offset += offset;
self
}
#[must_use]
pub(crate) fn advance_newline(&self) -> State<'a> {
let mut state = self.clone();
state.offset += 1;
state.line_start = state.pos();
state
#[inline(always)]
pub(crate) const fn advance_newline(mut self) -> State<'a> {
self.offset += 1;
self.line_start = self.pos();
self
}
/// Returns the current position