Skip to content

Conversation

@aarlt
Copy link
Collaborator

@aarlt aarlt commented Sep 28, 2022

Refactors solc/CommandLineInterface.cpp to make #12834 more readable.

Comment on lines 429 to 439
if (
m_options.input.mode == InputMode::Help ||
m_options.input.mode == InputMode::License ||
m_options.input.mode == InputMode::Version
)
if (std::set<InputMode>{InputMode::Help, InputMode::License, InputMode::Version}.count(m_options.input.mode) == 1)
Copy link
Collaborator

@cameel cameel Sep 28, 2022

Choose a reason for hiding this comment

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

To be honest, I think the previous version was much more readable even though it was less concise :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

We'll get set::contains when™ we upgrade to c++20 :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have our own version in CommonData.h.

But it would still look pretty much the same. Not a big deal, just pointing out that sometimes the stupid way to do it is cleaner :)


void CommandLineInterface::readInputFiles()
{
solAssert(!m_standardJsonInput.has_value(), "");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious because I've seen it all over the place - is this equivalent to your altered version where you don't pass ""? I.e. will this just terminate with an empty message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, this is equivalent to an empty message.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Until quite recently you could not skip the message (#12019). And it's just a tiny detail, so I don't think it makes sense to spend time replacing it all everywhere. We just sometimes remove the empty messages when we clean up code.

@aarlt aarlt force-pushed the valid-input-modes-refactoring branch from 199ed76 to cd440fc Compare October 18, 2022 20:15
@aarlt aarlt requested a review from cameel October 18, 2022 20:15
@cameel cameel merged commit 8830be9 into develop Oct 21, 2022
@cameel cameel deleted the valid-input-modes-refactoring branch October 21, 2022 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants