Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up JSON operator tokenizing code #923

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jul 17, 2023

This has some small cleanups of the changes made in #913 by @izveigor

@alamb alamb mentioned this pull request Jul 17, 2023
@alamb alamb marked this pull request as ready for review July 17, 2023 19:04
@@ -1086,8 +1079,8 @@ impl<'a> Tokenizer<'a> {
}

/// Tokenize an identifier or keyword, after the first char is already consumed.
fn tokenize_word(&self, first_chars: String, chars: &mut State) -> String {
let mut s = first_chars;
fn tokenize_word(&self, first_chars: impl Into<String>, chars: &mut State) -> String {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uses some generics to avoid having to manually construct Strings in several places.

@@ -934,19 +932,14 @@ impl<'a> Tokenizer<'a> {
match chars.peek() {
Some(' ') => Ok(Some(Token::AtAt)),
Some(tch) if self.dialect.is_identifier_start('@') => {
let mut s = ch.to_string();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the new construction is both less verbose and clearer about intent

Copy link
Contributor Author

@alamb alamb left a comment

Choose a reason for hiding this comment

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

cc @izveigor if you have a moment to review these changes I would appreciate it.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5579571678

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.006%) to 86.994%

Totals Coverage Status
Change from base Build 5579567719: -0.006%
Covered Lines: 15217
Relevant Lines: 17492

💛 - Coveralls

Copy link
Contributor

@Dandandan Dandandan left a comment

Choose a reason for hiding this comment

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

Nice cleanup

Copy link
Contributor

@izveigor izveigor left a comment

Choose a reason for hiding this comment

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

LGTM

@alamb alamb merged commit c454518 into apache:main Jul 17, 2023
9 checks passed
@alamb
Copy link
Contributor Author

alamb commented Jul 17, 2023

Thanks @Dandandan and @izveigor

@alamb alamb deleted the alamb/clean_up_json_code branch July 17, 2023 20:10
serprex pushed a commit to serprex/sqlparser-rs that referenced this pull request Nov 6, 2023
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.

4 participants