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

Simplify code where possible #4

Merged
merged 9 commits into from Oct 7, 2020

Conversation

JayKickliter
Copy link
Contributor

@JayKickliter JayKickliter commented Oct 5, 2020

This PR is a non-comprehensive1 effort to:

  • reduce temporary heap allocations
  • delete unnecessary code
  • improve readability

1: I have another branch with more aggressive, but API breaking, optimizations that remove a lot of heap allocations. I can open a follow-up PR for that along with a major version bump.

Constructing a new maxtrix via a closure saves us one zeriozation and
two temporary heap allocations.
Prefer:

1. sqrt over pow(0.5)
2. powi over powf when exponent is a whole number

(1) is detected by clippy. (2) is not, but it is called out in Rust's
documentation.

Additionally, enable clippy::suboptimal-flops in CI.
This helps to avoid intermediate allocations by skipping the step of
creating an intermediate Vec. This only affects test code, so it's not
a big deal, but sets the precedent for future contributers who may be
unfamiliar with ndarray's features.
@avinashshenoy97 avinashshenoy97 merged commit d830be4 into avinashshenoy97:master Oct 7, 2020
@avinashshenoy97
Copy link
Owner

Looking forward to it!

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.

None yet

2 participants