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

Bail out early from truncate if the new length is equal to the old #74172

Closed

Commits on Jul 9, 2020

  1. Don't truncate if new length is equal to old

    `truncate` should do nothing for collections if the new length is equal
    to the current length, but this was not reflected in the code. Instead,
    control flow continued until an empty slice was passed to
    `drop_in_place`.
    ecstatic-morse committed Jul 9, 2020
    Configuration menu
    Copy the full SHA
    8d0eded View commit details
    Browse the repository at this point in the history
  2. Implement Vec::clear by hand

    The new version of `truncate` compiles up a branch when called with a
    constant `0` and `T: !Drop`.
    ecstatic-morse committed Jul 9, 2020
    Configuration menu
    Copy the full SHA
    d88f09b View commit details
    Browse the repository at this point in the history