From a2ee7592d6b7c0daa62b7870ade85e0cc0acca05 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Fri, 31 Mar 2023 00:32:44 -0700 Subject: Use `&IndexSlice` instead of `&IndexVec` where possible All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*. --- compiler/rustc_data_structures/src/graph/dominators/mod.rs | 14 +++++++------- compiler/rustc_data_structures/src/graph/iterate/mod.rs | 4 ++-- compiler/rustc_data_structures/src/graph/scc/mod.rs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'compiler/rustc_data_structures/src/graph') diff --git a/compiler/rustc_data_structures/src/graph/dominators/mod.rs b/compiler/rustc_data_structures/src/graph/dominators/mod.rs index 0a21a4249c8..0df9dc112ee 100644 --- a/compiler/rustc_data_structures/src/graph/dominators/mod.rs +++ b/compiler/rustc_data_structures/src/graph/dominators/mod.rs @@ -10,7 +10,7 @@ //! use super::ControlFlowGraph; -use rustc_index::vec::{Idx, IndexVec}; +use rustc_index::vec::{Idx, IndexSlice, IndexVec}; use std::cmp::Ordering; #[cfg(test)] @@ -256,10 +256,10 @@ pub fn dominators(graph: G) -> Dominators { /// where `+>` is a proper ancestor and `*>` is just an ancestor. #[inline] fn eval( - ancestor: &mut IndexVec, + ancestor: &mut IndexSlice, lastlinked: Option, - semi: &IndexVec, - label: &mut IndexVec, + semi: &IndexSlice, + label: &mut IndexSlice, node: PreorderIndex, ) -> PreorderIndex { if is_processed(node, lastlinked) { @@ -277,10 +277,10 @@ fn is_processed(v: PreorderIndex, lastlinked: Option) -> bool { #[inline] fn compress( - ancestor: &mut IndexVec, + ancestor: &mut IndexSlice, lastlinked: Option, - semi: &IndexVec, - label: &mut IndexVec, + semi: &IndexSlice, + label: &mut IndexSlice, v: PreorderIndex, ) { assert!(is_processed(v, lastlinked)); diff --git a/compiler/rustc_data_structures/src/graph/iterate/mod.rs b/compiler/rustc_data_structures/src/graph/iterate/mod.rs index 8a9af300c06..01a83b40a75 100644 --- a/compiler/rustc_data_structures/src/graph/iterate/mod.rs +++ b/compiler/rustc_data_structures/src/graph/iterate/mod.rs @@ -1,6 +1,6 @@ use super::{DirectedGraph, WithNumNodes, WithStartNode, WithSuccessors}; use rustc_index::bit_set::BitSet; -use rustc_index::vec::IndexVec; +use rustc_index::vec::{IndexSlice, IndexVec}; use std::ops::ControlFlow; #[cfg(test)] @@ -31,7 +31,7 @@ fn post_order_walk( graph: &G, node: G::Node, result: &mut Vec, - visited: &mut IndexVec, + visited: &mut IndexSlice, ) { struct PostOrderFrame { node: Node, diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index c4b11951ab7..28c357e54dd 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -8,7 +8,7 @@ use crate::fx::FxHashSet; use crate::graph::vec_graph::VecGraph; use crate::graph::{DirectedGraph, GraphSuccessors, WithNumEdges, WithNumNodes, WithSuccessors}; -use rustc_index::vec::{Idx, IndexVec}; +use rustc_index::vec::{Idx, IndexSlice, IndexVec}; use std::ops::Range; #[cfg(test)] @@ -43,7 +43,7 @@ impl Sccs { SccsConstruction::construct(graph) } - pub fn scc_indices(&self) -> &IndexVec { + pub fn scc_indices(&self) -> &IndexSlice { &self.scc_indices } @@ -123,7 +123,7 @@ impl SccData { self.ranges.len() } - pub fn ranges(&self) -> &IndexVec> { + pub fn ranges(&self) -> &IndexSlice> { &self.ranges } -- cgit 1.4.1-3-g733a5