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

Refactored the lex function in the BlockDirectiveParser file. #128

Merged
merged 2 commits into from
May 30, 2023

Conversation

Mayank-84
Copy link

Summary

  • This PR refactors the current implementation of lex function of the TrimmedLine. It's intended to make the code more readable and concise without breaking the existing intended functionality.
  • In the updated implementation, instead of incrementing the takeCount var (within while loop) at every certain conditions, it will update the takeCount only once at the end.
  • Also, instead of checking for if condition to populate the isQuoted var, we can directly use the boolean result of != relational operator to populate the variable.
  • This makes the code concise and more easier to debug and dry-run the while loop.

Testing

I believe this is a minor refactoring and doesn't require any new tests. All the existing test cases was passing. 💯

Checklist

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

Note

  • This is my first ever contribution to this repository. I made sure that I read the contributing guidelines.
  • Still if there's anything I can improve, please give your feedback, would love to work on that. 👨‍💻

Mayank added 2 commits May 27, 2023 15:19
…iveParser

- Instead of incrementing the take count at every if conditions. We can increment at the end directly.
- This make code concise and hence easier to read and debug the while loop.
- Instead of checking for `if` condition to populate the `isQuoted` var, we can directly use the boolean result of `!=` relational operator to populate the variable.

- This makes the code concise and more easier to debug and dry-run the while loop.
@QuietMisdreavus
Copy link
Contributor

@swift-ci Please test

Copy link
Contributor

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

This looks great, thanks!

@QuietMisdreavus QuietMisdreavus merged commit 8ea3072 into swiftlang:main May 30, 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.

2 participants