remove get_many_mut since it was stabilized in std as get_disjoint_mut
This commit is contained in:
parent
65f9ab32f4
commit
ae7c4be9dc
3 changed files with 17 additions and 33 deletions
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
intern::{Intern, Interned, Memoize},
|
intern::{Intern, Interned, Memoize},
|
||||||
source_location::SourceLocation,
|
source_location::SourceLocation,
|
||||||
ty::CanonicalType,
|
ty::CanonicalType,
|
||||||
util::{get_many_mut, HashMap, HashSet},
|
util::{HashMap, HashSet},
|
||||||
};
|
};
|
||||||
use bitvec::{boxed::BitBox, slice::BitSlice};
|
use bitvec::{boxed::BitBox, slice::BitSlice};
|
||||||
use num_bigint::BigInt;
|
use num_bigint::BigInt;
|
||||||
|
@ -2078,16 +2078,16 @@ impl<
|
||||||
BorrowedState<'a>: DerefMut<Target: IndexMut<usize, Output = T> + BorrowMut<[T]>>,
|
BorrowedState<'a>: DerefMut<Target: IndexMut<usize, Output = T> + BorrowMut<[T]>>,
|
||||||
>,
|
>,
|
||||||
T,
|
T,
|
||||||
> BorrowedStatePart<'a, K>
|
> BorrowedStatePart<'a, K>
|
||||||
{
|
{
|
||||||
pub(crate) fn get_many_mut<const N: usize>(
|
pub(crate) fn get_disjoint_mut<const N: usize>(
|
||||||
&mut self,
|
&mut self,
|
||||||
indexes: [StatePartIndex<K>; N],
|
indexes: [StatePartIndex<K>; N],
|
||||||
) -> [&mut T; N] {
|
) -> [&mut T; N] {
|
||||||
get_many_mut(
|
(*self.value)
|
||||||
(*self.value).borrow_mut(),
|
.borrow_mut()
|
||||||
indexes.map(|v| v.value as usize),
|
.get_disjoint_mut(indexes.map(|v| v.value as usize))
|
||||||
)
|
.expect("indexes are disjoint")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2568,7 +2568,7 @@ impl_insns! {
|
||||||
src: StatePartIndex<StatePartKindBigSlots>,
|
src: StatePartIndex<StatePartKindBigSlots>,
|
||||||
} => {
|
} => {
|
||||||
if dest != src {
|
if dest != src {
|
||||||
let [dest, src] = state.big_slots.get_many_mut([dest, src]);
|
let [dest, src] = state.big_slots.get_disjoint_mut([dest, src]);
|
||||||
dest.clone_from(src);
|
dest.clone_from(src);
|
||||||
}
|
}
|
||||||
next!();
|
next!();
|
||||||
|
@ -2590,7 +2590,7 @@ impl_insns! {
|
||||||
} => {
|
} => {
|
||||||
if let Some(src) = state.eval_array_indexed(src) {
|
if let Some(src) = state.eval_array_indexed(src) {
|
||||||
if dest != src {
|
if dest != src {
|
||||||
let [dest, src] = state.big_slots.get_many_mut([dest, src]);
|
let [dest, src] = state.big_slots.get_disjoint_mut([dest, src]);
|
||||||
dest.clone_from(src);
|
dest.clone_from(src);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2619,7 +2619,7 @@ impl_insns! {
|
||||||
} => {
|
} => {
|
||||||
if let Some(dest) = state.eval_array_indexed(dest) {
|
if let Some(dest) = state.eval_array_indexed(dest) {
|
||||||
if dest != src {
|
if dest != src {
|
||||||
let [dest, src] = state.big_slots.get_many_mut([dest, src]);
|
let [dest, src] = state.big_slots.get_disjoint_mut([dest, src]);
|
||||||
dest.clone_from(src);
|
dest.clone_from(src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ pub use scoped_ref::ScopedRef;
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use misc::{
|
pub use misc::{
|
||||||
get_many_mut, interned_bit, iter_eq_by, BitSliceWriteWithBase, DebugAsDisplay,
|
BitSliceWriteWithBase, DebugAsDisplay, DebugAsRawString, MakeMutSlice, RcWriter, interned_bit,
|
||||||
DebugAsRawString, MakeMutSlice, RcWriter,
|
iter_eq_by,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod job_server;
|
pub mod job_server;
|
||||||
|
|
|
@ -163,22 +163,6 @@ impl fmt::UpperHex for BitSliceWriteWithBase<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[track_caller]
|
|
||||||
pub fn get_many_mut<T, const N: usize>(slice: &mut [T], indexes: [usize; N]) -> [&mut T; N] {
|
|
||||||
for i in 0..N {
|
|
||||||
for j in 0..i {
|
|
||||||
assert!(indexes[i] != indexes[j], "duplicate index");
|
|
||||||
}
|
|
||||||
assert!(indexes[i] < slice.len(), "index out of bounds");
|
|
||||||
}
|
|
||||||
// Safety: checked that no indexes are duplicates and no indexes are out of bounds
|
|
||||||
unsafe {
|
|
||||||
let base = slice.as_mut_ptr(); // convert to a raw pointer before loop to avoid aliasing with &mut [T]
|
|
||||||
std::array::from_fn(|i| &mut *base.add(indexes[i]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct RcWriter(Rc<Cell<Vec<u8>>>);
|
pub struct RcWriter(Rc<Cell<Vec<u8>>>);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue