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

refactor: tidy up compiler #12874

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

refactor: tidy up compiler #12874

wants to merge 6 commits into from

Conversation

Simon-He95
Copy link

@Simon-He95 Simon-He95 commented Nov 9, 2022

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@sxzz sxzz changed the title refactor:tidy up compiler/codegen refactor: tidy up compiler/codegen Nov 18, 2022
@Simon-He95 Simon-He95 changed the title refactor: tidy up compiler/codegen refactor: tidy up compiler Nov 18, 2022
@Justineo
Copy link
Member

In general, I'm not a big fan of small refactorings like this when there are no obvious readability issues with the original code, which would make the history of the real logic changes harder to track.

@Simon-He95
Copy link
Author

I think this will make the logical distinction more obvious. If it is not satisfied, it will return directly, and it will reduce the situation where the nesting level of many conditions is deep and the code readability is poor.

@Justineo
Copy link
Member

I'm not saying that early return is not a useful pattern, and I use it myself. Rather, for code that has been around for a long time and without obvious readability issues, the benefits may not outweigh the costs. The costs include, but are not limited to, the cost of review by maintainers, the additional complexity of tracking changes to the code.

@haoqunjiang
Copy link
Member

haoqunjiang commented Nov 19, 2022

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.

5 participants