diff options
| author | bors <bors@rust-lang.org> | 2023-08-01 16:09:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-01 16:09:13 +0000 |
| commit | 4896daa3985010e7d136fe0c5bf4c4e8bfc911ae (patch) | |
| tree | 4daf7dcc56c274b7786e104e1ecd0504b3152a6e /compiler/rustc_data_structures/src | |
| parent | 828bdc2c26f5c95773c4ecf72870919f16417b66 (diff) | |
| parent | 41364c7c1d7142532b747100177c8b889475dde3 (diff) | |
| download | rust-4896daa3985010e7d136fe0c5bf4c4e8bfc911ae.tar.gz rust-4896daa3985010e7d136fe0c5bf4c4e8bfc911ae.zip | |
Auto merge of #114331 - matthiaskrgr:rollup-rnrmwcx, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #100455 (Implement RefUnwindSafe for Backtrace) - #113428 (coverage: Replace `ExpressionOperandId` with enum `Operand`) - #114283 (Use parking lot's rwlock even without parallel-rustc) - #114288 (Improve diagnostic for wrong borrow on binary operations) - #114296 (interpret: fix alignment handling for Repeat expressions) - #114306 ([rustc_data_structures][perf] Simplify base_n::push_str.) - #114320 (Cover statements for stable_mir) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/base_n.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/sync/vec.rs | 28 |
2 files changed, 10 insertions, 25 deletions
diff --git a/compiler/rustc_data_structures/src/base_n.rs b/compiler/rustc_data_structures/src/base_n.rs index 4567759c004..58704350706 100644 --- a/compiler/rustc_data_structures/src/base_n.rs +++ b/compiler/rustc_data_structures/src/base_n.rs @@ -16,22 +16,21 @@ const BASE_64: &[u8; MAX_BASE] = pub fn push_str(mut n: u128, base: usize, output: &mut String) { debug_assert!(base >= 2 && base <= MAX_BASE); let mut s = [0u8; 128]; - let mut index = 0; + let mut index = s.len(); let base = base as u128; loop { + index -= 1; s[index] = BASE_64[(n % base) as usize]; - index += 1; n /= base; if n == 0 { break; } } - s[0..index].reverse(); - output.push_str(str::from_utf8(&s[0..index]).unwrap()); + output.push_str(str::from_utf8(&s[index..]).unwrap()); } #[inline] diff --git a/compiler/rustc_data_structures/src/sync/vec.rs b/compiler/rustc_data_structures/src/sync/vec.rs index e36dded9e5e..314496ce9f0 100644 --- a/compiler/rustc_data_structures/src/sync/vec.rs +++ b/compiler/rustc_data_structures/src/sync/vec.rs @@ -43,37 +43,23 @@ 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>, + vec: parking_lot::RwLock<Vec<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: Default::default() } } 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 + let mut v = self.vec.write(); + let n = v.len(); + v.push(val); + n } 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.read().get(i).copied() } pub fn iter_enumerated(&self) -> impl Iterator<Item = (usize, T)> + '_ { |
