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

Reuse existing small allocations if possible #12335

Merged
merged 4 commits into from Mar 30, 2024

Commits on Mar 30, 2024

  1. Avoid reallocs with clone_from in nu-parser

    - Associated clippy lint
    https://rust-lang.github.io/rust-clippy/master/index.html#/clone_from
    - This can save some allocations or drops by explicitly optimizing here.
    - `Clone::clone_from` should provide pretty readable semantics
    - `ToOwned::clone_into` maybe requires a bit more familiarity
    sholderbach committed Mar 30, 2024
    Configuration menu
    Copy the full SHA
    126affb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1cf1b07 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    40a5735 View commit details
    Browse the repository at this point in the history
  4. Reuse allocations in nu-explore if possible

    - `String::clear(&mut self)` instead of assigning `String::new()`
    - `Clone::clone_from` instead of assigning new allocations
    - https://rust-lang.github.io/rust-clippy/master/index.html#/clone_from
    
    Still some places that may be better expressed by e.g. `std::mem::take`
    when passing around `String`s, but that could also be revisited with
    good use of references
    sholderbach committed Mar 30, 2024
    Configuration menu
    Copy the full SHA
    7b17307 View commit details
    Browse the repository at this point in the history