Skip to content

simplify a switch statement#70

Closed
glessard wants to merge 1 commit into
apple:masterfrom
glessard:argumentset-flagupdate-exhaustive-switch
Closed

simplify a switch statement#70
glessard wants to merge 1 commit into
apple:masterfrom
glessard:argumentset-flagupdate-exhaustive-switch

Conversation

@glessard
Copy link
Copy Markdown
Contributor

@glessard glessard commented Mar 6, 2020

This change has no effect on functionality, documentation or testing.

The switch in ArgumentSet.flagUpdate (originally in one of the Flag constructors) switches on 3 items, one of which (the return value of values.element(forKey:)) is needed in only one of the 12 possibilities. This moves the call to values.element(forKey:) into the one case where it is needed. The function becomes slightly more efficient, and the switch is more readable (down to 6 possibilities), and no longer needs a default case. Note that the probably-impossible failure mode where values.element(forKey: key returns nil and hasUpdated is true still results in the same behaviour, namely the argument is unused and the function returns true; this eventually leads to a call to ErrorMessageGenerator.unknownOptionMessage.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@glessard glessard mentioned this pull request Mar 7, 2020
4 tasks
@glessard
Copy link
Copy Markdown
Contributor Author

glessard commented Mar 7, 2020

Superseded by #71

@glessard glessard closed this Mar 7, 2020
@glessard glessard deleted the argumentset-flagupdate-exhaustive-switch branch March 9, 2020 17:00
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.

1 participant