Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Avoid unnecessary force-unwrapping or nil-coalescing #138

Closed
blochberger opened this issue Jun 2, 2020 · 2 comments
Closed

Avoid unnecessary force-unwrapping or nil-coalescing #138

blochberger opened this issue Jun 2, 2020 · 2 comments
Assignees
Labels
alternative approaches Alternative approaches Proposals for solutions that differ from current implementations

Comments

@blochberger
Copy link

There is a lot of unnecessary force-unwrapping or nil-coalescing in the code, e. g.:

static let binHeader = "EK Export v1 ".data(using: .utf8)!

or

let value = SHA256.hash(data: input.data(using: .utf8) ?? Data())

The conversion from String to UTF-8 encoded Data cannot fail. A non-optional conversion can be done:

let string: String = "foobar"
let data: Data = Data(string.utf8)
@tkowark tkowark added the alternative approaches Alternative approaches Proposals for solutions that differ from current implementations label Jun 2, 2020
@tkowark
Copy link
Member

tkowark commented Jun 2, 2020

Thanks for the enhancement proposal, @blochberger !

As the team is working full steam towards the planned release, it would help us a lot, if you could give us some more information about the potential benefits of your proposal. Ideally, you can follow (and in the future use) the respective template.

The background simply is that we have to pick wisely, which improvements to implement now, and which ones to tackle in a future release. To better assess that, just a rough outline of the expected benefits (readability, error-proneness, performance, etc.) would really be of huge assistance!

@ChristianKienle ChristianKienle self-assigned this Jun 9, 2020
@ChristianKienle
Copy link
Contributor

will be fixed by #402. Thank you very much for pointing out those unnecessary forced unwraps / default values.

@inf2381 inf2381 closed this as completed in 070d30e Jun 9, 2020
inf2381 added a commit that referenced this issue Jun 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
alternative approaches Alternative approaches Proposals for solutions that differ from current implementations
Projects
None yet
Development

No branches or pull requests

3 participants