| commit | bd33b83cfdbac9bffa3b04aaef95ec97827909a9 | [log] [tgz] |
|---|---|---|
| author | bors <bors@rust-lang.org> | Mon Jan 05 14:55:14 2026 +0000 |
| committer | bors <bors@rust-lang.org> | Mon Jan 05 14:55:14 2026 +0000 |
| tree | 3d70d2d287c4af36fff93ef5d8a93e4dbf890971 | |
| parent | b7bcaa5c715ed07af2d74dac7ddb8786abeb4299 [diff] | |
| parent | bd79ea1b743cccde61ffda92ba4f41abdfab515c [diff] |
Auto merge of #149784 - fereidani:retain_mut, r=joboet Improve alloc `Vec::retain_mut` performance Hi, While reading the rustc source code, I noticed it uses `smallvec` and `thin-vec` in many places. I started reviewing those crates, optimized their `retain_mut` implementation, and then realized they were using the exact same algorithm as `alloc::vec::Vec` with less unsafe So now I’m back here with a PR for the standard library 😂. In my benchmarks, this version is noticeably faster when `retain_mut` actually removes elements (thanks to fewer pointer operations, it just advances `write_index`), while performing identically to the current implementation when nothing is removed. Let’s see if bors likes this change or not.
Website | Getting started | Learn | Documentation | Contributing
This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.
Performance: Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrated with other languages.
Reliability: Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.
Productivity: Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool (Cargo), auto-formatter (rustfmt), linter (Clippy) and editor support (rust-analyzer).
Read “Installation” from The Book.
If you really want to install from source (though this is not recommended), see INSTALL.md.
See https://www.rust-lang.org/community for a list of chat platforms and forums.
See CONTRIBUTING.md.
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.
The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the “Rust Trademarks”).
If you want to use these names or brands, please read the Rust language trademark policy.
Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.