You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
♻️ Refactor getStaticParameter to valueToDouble (#1443)
## Description
This PR reduces the current code duplication of `getStaticParameter`
which is used in both `QC` and `QCO`.
It additionally adds the conversion to a standard C++ double type since
there is no other use of the function in the code base so far.
An alternative to the currently returned `std::optional` would be a
`llvm::FailureOr<double>` which is simply a subclass of `std::optional`.
However, it is in my opinion slightly more annoying to use since it
requires `llvm::succeeded` and `llvm::failed` to check the result
instead of the implicit conversion to bool available in `std::optional`.
This is meant to make it slightly safer to use, but makes the code also
more verbose and less convenient which is why I decided against using
it. `std::optional` is an established standard C++ tool and people
usually know how to handle it correctly which cannot be said for
`llvm::FailureOr<double>`.
Required for #1426
## Checklist:
<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->
- [ ] The pull request only contains commits that are focused and
relevant to this change.
- [ ] I have added appropriate tests that cover the new/changed
functionality.
- [ ] I have updated the documentation to reflect these changes.
- [ ] I have added entries to the changelog for any noteworthy
additions, changes, fixes, or removals.
- [ ] I have added migration instructions to the upgrade guide (if
needed).
- [ ] The changes follow the project's style guidelines and introduce no
new warnings.
- [ ] The changes are fully tested and pass the CI checks.
- [ ] I have reviewed my own code changes.
---------
Signed-off-by: Tamino Bauknecht <28907748+taminob@users.noreply.github.com>
Co-authored-by: Lukas Burgholzer <burgholzer@me.com>
0 commit comments