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},
|
||||
source_location::SourceLocation,
|
||||
ty::CanonicalType,
|
||||
util::{get_many_mut, HashMap, HashSet},
|
||||
util::{HashMap, HashSet},
|
||||
};
|
||||
use bitvec::{boxed::BitBox, slice::BitSlice};
|
||||
use num_bigint::BigInt;
|
||||
|
@ -2080,14 +2080,14 @@ impl<
|
|||
T,
|
||||
> BorrowedStatePart<'a, K>
|
||||
{
|
||||
pub(crate) fn get_many_mut<const N: usize>(
|
||||
pub(crate) fn get_disjoint_mut<const N: usize>(
|
||||
&mut self,
|
||||
indexes: [StatePartIndex<K>; N],
|
||||
) -> [&mut T; N] {
|
||||
get_many_mut(
|
||||
(*self.value).borrow_mut(),
|
||||
indexes.map(|v| v.value as usize),
|
||||
)
|
||||
(*self.value)
|
||||
.borrow_mut()
|
||||
.get_disjoint_mut(indexes.map(|v| v.value as usize))
|
||||
.expect("indexes are disjoint")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2568,7 +2568,7 @@ impl_insns! {
|
|||
src: StatePartIndex<StatePartKindBigSlots>,
|
||||
} => {
|
||||
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);
|
||||
}
|
||||
next!();
|
||||
|
@ -2590,7 +2590,7 @@ impl_insns! {
|
|||
} => {
|
||||
if let Some(src) = state.eval_array_indexed(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);
|
||||
}
|
||||
} else {
|
||||
|
@ -2619,7 +2619,7 @@ impl_insns! {
|
|||
} => {
|
||||
if let Some(dest) = state.eval_array_indexed(dest) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ pub use scoped_ref::ScopedRef;
|
|||
|
||||
#[doc(inline)]
|
||||
pub use misc::{
|
||||
get_many_mut, interned_bit, iter_eq_by, BitSliceWriteWithBase, DebugAsDisplay,
|
||||
DebugAsRawString, MakeMutSlice, RcWriter,
|
||||
BitSliceWriteWithBase, DebugAsDisplay, DebugAsRawString, MakeMutSlice, RcWriter, interned_bit,
|
||||
iter_eq_by,
|
||||
};
|
||||
|
||||
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)]
|
||||
pub struct RcWriter(Rc<Cell<Vec<u8>>>);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue