diff options
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/graph/mod.rs | 7 | ||||
| -rw-r--r-- | src/librustc_data_structures/snapshot_vec.rs | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/librustc_data_structures/graph/mod.rs b/src/librustc_data_structures/graph/mod.rs index a5f83ce05f5..474622f3669 100644 --- a/src/librustc_data_structures/graph/mod.rs +++ b/src/librustc_data_structures/graph/mod.rs @@ -114,6 +114,13 @@ impl<N: Debug, E: Debug> Graph<N, E> { } } + pub fn with_capacity(nodes: usize, edges: usize) -> Graph<N, E> { + Graph { + nodes: SnapshotVec::with_capacity(nodes), + edges: SnapshotVec::with_capacity(edges), + } + } + // # Simple accessors #[inline] diff --git a/src/librustc_data_structures/snapshot_vec.rs b/src/librustc_data_structures/snapshot_vec.rs index dac074ab91e..2da91918288 100644 --- a/src/librustc_data_structures/snapshot_vec.rs +++ b/src/librustc_data_structures/snapshot_vec.rs @@ -66,6 +66,13 @@ impl<D: SnapshotVecDelegate> SnapshotVec<D> { } } + pub fn with_capacity(n: usize) -> SnapshotVec<D> { + SnapshotVec { + values: Vec::with_capacity(n), + undo_log: Vec::new(), + } + } + fn in_snapshot(&self) -> bool { !self.undo_log.is_empty() } |
