Skip to content

Removed redundant check #14952

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

Merged

Conversation

PycKamil
Copy link
Contributor

@PycKamil PycKamil commented Mar 3, 2018

Because initialising Int with empty string returns nil there is no need for this additional check for empty string. This should simplify this code a bit.

Since init for Int with empty string returns nil there is no need for additional checking for empty string
@@ -208,9 +208,6 @@ struct TestConfig {
}

if let x = benchArgs.optionalArgsMap["--sleep"] {
if x.isEmpty {
return .fail("--sleep requires a non-empty integer value")
}
let v: Int? = Int(x)
if v == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good point! Couldn't you simplify this further by using a guard let? I.e.:

if let x = benchArgs.optionalArgsMap["--sleep"] {
  guard let v = Int(x) else {
    return .fail("...")
  }
  afterRunSleep = v
}

Copy link
Contributor Author

@PycKamil PycKamil Mar 3, 2018

Choose a reason for hiding this comment

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

Yes I can, thats even better now

@gottesmm
Copy link
Contributor

gottesmm commented Mar 3, 2018

LGTM

@gottesmm
Copy link
Contributor

gottesmm commented Mar 3, 2018

@swift-ci smoke test and merge

@swift-ci swift-ci merged commit 26c08fb into swiftlang:master Mar 4, 2018
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.

3 participants