Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

MeirShpilraien
Copy link

No description provided.

@MeirShpilraien MeirShpilraien requested a review from gkorland July 20, 2021 12:18
@MeirShpilraien
Copy link
Author

@gkorland I believe we can optimize even more but maybe it will be good to check if see that it makes a difference ...

@gkorland gkorland requested review from gavrie and oshadmi July 21, 2021 11:41
}

match ch {
CH_DOLLA => self.dolla(pos, ch),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about this DOLLA / dolla spelling... do you know if this is a typo or on purpose? maybe we should fix it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, this is how it is on the main repository..

pub fn next_token(&mut self) -> Result<Token, TokenError> {
let (pos, ch) = self.input.next_char().map_err(to_token_error)?;
pub fn next_token(&mut self) -> Result<Token<'a>, TokenError> {
let (pos, ch) = self.input.peek_char().map_err(to_token_error)?;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the logic, but are we changing behavior here? What are the situations in which we do peek instead of next as compared to the original?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code was creating a new string. So it used next, saw the $, took the string after, and added it to char $. Now we do not want to compose a new string but return a slice that points to the original string, so we peek the next char, advance if needed (if its not $), and if it is $ we take the entire slice (including the $).

@MeirShpilraien MeirShpilraien requested review from oshadmi and removed request for oshadmi August 5, 2021 06:13
Copy link

@oshadmi oshadmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question 🤔

pub fn peek_char(&self) -> Result<(usize, char), ReaderError> {
let ch = self.input.chars().next().ok_or(ReaderError::Eof)?;
Ok((self.pos + ch.len_utf8(), ch))
Ok((self.pos, ch))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug fix regardless of using slices, right?
Avoiding advancing the position when peeking? (should be advanced on next_char and take_while)

Copy link

@oshadmi oshadmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment

Copy link

@oshadmi oshadmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 LGTM

@MeirShpilraien MeirShpilraien merged commit 14af7aa into generic_json_path Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants