Skip to content
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

refactor: Improve efficiency and readability #68

Merged
merged 3 commits into from
Jul 9, 2024
Merged

refactor: Improve efficiency and readability #68

merged 3 commits into from
Jul 9, 2024

Conversation

shuhuiluo
Copy link
Collaborator

No description provided.

shuhuiluo added 3 commits July 9, 2024 00:06
The brackets around the arithmetic operations in the fraction.rs and percent.rs test functions have been removed to improve readability. Also, in compute_price_impact.rs tests, the 'assert!' function has been replaced with 'assert_eq!' to enhance precision and clarity of the tests.
Simplify the `compute_price_impact` function by eliminating the need for manual error handling and using the question mark operator instead. This change also eliminates the need for clone of price impact, making the function more efficient and cleaner.
The square root function for BigInt has been simplified. The previous implementation used a combination of primitive sqrt for smaller values and Babylonian method for larger ones. Now, the function uses the in-built sqrt method regardless of the input size, simplifying the code and reducing potential errors.
@shuhuiluo shuhuiluo requested a review from malik672 July 9, 2024 07:17
@shuhuiluo shuhuiluo self-assigned this Jul 9, 2024
@malik672 malik672 merged commit 44aed2c into deps Jul 9, 2024
2 checks passed
malik672 pushed a commit that referenced this pull request Jul 9, 2024
* chore: Update package versions and adjust test assertions

The package versions in Cargo.toml have been updated including 'bigdecimal', 'lazy_static', 'num-traits' and few others. In the same commit, the assertion methodology in the test cases for the 'Price' entity has been changed to increase precision. Also, the expected results for 'to_significant' tests have been replaced with new values in scientific notation.

* refactor: Improve efficiency and readability (#68)

* Refactor code for fraction and percent tests

The brackets around the arithmetic operations in the fraction.rs and percent.rs test functions have been removed to improve readability. Also, in compute_price_impact.rs tests, the 'assert!' function has been replaced with 'assert_eq!' to enhance precision and clarity of the tests.

* Refactor `compute_price_impact` function

Simplify the `compute_price_impact` function by eliminating the need for manual error handling and using the question mark operator instead. This change also eliminates the need for clone of price impact, making the function more efficient and cleaner.

* Refactor `sqrt` function for `BigInt`

The square root function for BigInt has been simplified. The previous implementation used a combination of primitive sqrt for smaller values and Babylonian method for larger ones. Now, the function uses the in-built sqrt method regardless of the input size, simplifying the code and reducing potential errors.
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.

2 participants