diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-17 18:10:54 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-27 20:02:18 +0000 |
| commit | 209eb8ae83105802be5ff2c1204a4d3aae9839b3 (patch) | |
| tree | 8f93b5a467a11e1e4342d7be84b5301eb5ae6b01 /compiler/rustc_mir_transform/src | |
| parent | 2a32a2b64faf52b65080ea84b5bc110627294954 (diff) | |
| download | rust-209eb8ae83105802be5ff2c1204a4d3aae9839b3.tar.gz rust-209eb8ae83105802be5ff2c1204a4d3aae9839b3.zip | |
Do not grow `assignment_order` needlessly.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/ssa.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index 0bb97c4fc09..73168652f8f 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -53,7 +53,7 @@ impl SsaLocals { body: &Body<'tcx>, borrowed_locals: &BitSet<Local>, ) -> SsaLocals { - let assignment_order = Vec::new(); + let assignment_order = Vec::with_capacity(body.local_decls.len()); let assignments = IndexVec::from_elem(Set1::Empty, &body.local_decls); let dominators = @@ -203,7 +203,10 @@ impl<'tcx> Visitor<'tcx> for SsaVisitor { match ctxt { PlaceContext::MutatingUse(MutatingUseContext::Store) => { self.assignments[local].insert(LocationExtended::Plain(loc)); - self.assignment_order.push(local); + if let Set1::One(_) = self.assignments[local] { + // Only record if SSA-like, to avoid growing the vector needlessly. + self.assignment_order.push(local); + } } // Anything can happen with raw pointers, so remove them. PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) |
