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 ToIrListener id generation #1085

Merged
merged 1 commit into from
Aug 1, 2023
Merged

Conversation

shonfeder
Copy link
Contributor

This is a small refactor supporting #1082

Add a helper function to generate location IDs and register them into
the source map. These must always go together, so adding the two into
the same function saves a number of lines and makes the code safer since
it ensures we won't miss a needed addition to the map.


  • [-] Tests added for any new code
  • [-] Documentation added for any new functionality
  • [-] Entries added to the respective CHANGELOG.md for any new functionality
  • [-] Feature table on README.md updated for any listed functionality

Add a helper function to generate location IDs and register them into
the source map. These must always go together, so adding the two into
the same function saves a number of lines and makes the code safer since
it ensures we won't miss a needed addition to the map.
@shonfeder shonfeder requested a review from thpani August 1, 2023 02:36
@thpani thpani disabled auto-merge August 1, 2023 09:28
Copy link
Contributor

@thpani thpani left a comment

Choose a reason for hiding this comment

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

Looks good!

Is the side-effect obvious enough to not reflect it in the name (e.g. getIdAndUpdateSourceMap() vs getId())?

@shonfeder
Copy link
Contributor Author

Thanks for the review!

Is the side-effect obvious enough to not reflect it in the name

Given that the method is private and commented, I feel it is nice and convenient to phrase it is I did here. The map updates is really an implementation detail happening behind the scenes, and there's no reason for the adder for a visitor method to think about it.

I could encapsulate the id gen and map update in a class, but seems a bit overkill here.

@shonfeder shonfeder merged commit cc195bc into main Aug 1, 2023
15 checks passed
@shonfeder shonfeder deleted the sf/refactor-listener-id-gen branch August 1, 2023 13:19
@shonfeder shonfeder self-assigned this Aug 2, 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