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

A bunch of small optimisations #3182

Merged
merged 3 commits into from
Oct 14, 2022
Merged

A bunch of small optimisations #3182

merged 3 commits into from
Oct 14, 2022

Conversation

klochowicz
Copy link
Contributor

See commit details.

`with_multiplicities` bool cannot have 3 states; `None` was evaluated to false
    internally anyway.
@@ -240,8 +239,7 @@ impl Div<Price> for Contracts {
fn div(self, rhs: Price) -> Self::Output {
let mut btc = self.0 / rhs.0;
btc.rescale(8);
Amount::from_str_in(&btc.to_string(), Denomination::Bitcoin)
.expect("Error computing BTC amount")
Amount::from_btc(btc.to_f64().expect("to fit in f64")).expect("Parse the BTC amount")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does the same thing underthehood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not quite - we avoid using Decimals Display implementation, which is AFAICT not as straightforward as f64 (regular float).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but good point that Amount::from_btc creates a String. I have overlooked that.

@klochowicz
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 14, 2022

Build succeeded:

@bors bors bot merged commit 86fae7a into master Oct 14, 2022
@bors bors bot deleted the small-fixes branch October 14, 2022 00:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants