Skip to content

Conversation

@stepancheg
Copy link
Contributor

  • push_all* operations should reserve capacity before pushing data to avoid unnecessary reallocations
  • reserve_exact should never shrink, as specified in documentation

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method could be written as just:

fn push_all(&mut self, other: &[T]) {
     self.extend(other.iter().map(|e| e.clone())
}

and similarly self.extend(other.move_iter()) for push_all_move. The extend implementation includes the size reservation, and so this is more DRY etc.

reserve_exact should not shrink according to documentation.
It is shorter and also fixes missed reserve call.
@stepancheg
Copy link
Contributor Author

Updated patch: push_all* now calls extend.

bors added a commit that referenced this pull request Apr 2, 2014
* push_all* operations should reserve capacity before pushing data to avoid unnecessary reallocations
* reserve_exact should never shrink, as specified in documentation
@bors bors closed this Apr 2, 2014
@bors bors merged commit 026d206 into rust-lang:master Apr 2, 2014
Jarcho pushed a commit to Jarcho/rust that referenced this pull request Aug 24, 2024
…xFrednet

Fix confusing message in double_must_use lint

Close rust-lang#13003
As mentioned at rust-lang#13003 it isn't quite clear what it means "an empty `#[must_use]` attribute" so clarify it

changelog: [none]
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.

5 participants