Skip to content

Commit

Permalink
WIP: Perf test always using the parallel-rustc code path
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jul 31, 2023
1 parent 03b8b50 commit b6fc18a
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions compiler/rustc_data_structures/src/sync/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,20 @@ impl<I: Idx, T: Copy> AppendOnlyIndexVec<I, T> {

#[derive(Default)]
pub struct AppendOnlyVec<T: Copy> {
#[cfg(not(parallel_compiler))]
vec: elsa::vec::FrozenVec<T>,
#[cfg(parallel_compiler)]
vec: elsa::sync::LockFreeFrozenVec<T>,
}

impl<T: Copy> AppendOnlyVec<T> {
pub fn new() -> Self {
Self {
#[cfg(not(parallel_compiler))]
vec: elsa::vec::FrozenVec::new(),
#[cfg(parallel_compiler)]
vec: elsa::sync::LockFreeFrozenVec::new(),
}
Self { vec: elsa::sync::LockFreeFrozenVec::new() }
}

pub fn push(&self, val: T) -> usize {
#[cfg(not(parallel_compiler))]
let i = self.vec.len();
#[cfg(not(parallel_compiler))]
self.vec.push(val);
#[cfg(parallel_compiler)]
let i = self.vec.push(val);
i
self.vec.push(val)
}

pub fn get(&self, i: usize) -> Option<T> {
#[cfg(not(parallel_compiler))]
return self.vec.get_copy(i);
#[cfg(parallel_compiler)]
return self.vec.get(i);
self.vec.get(i)
}

pub fn iter_enumerated(&self) -> impl Iterator<Item = (usize, T)> + '_ {
Expand Down

0 comments on commit b6fc18a

Please sign in to comment.