Rollup merge of #151178 - ua/fixme, r=Kivooeo
simplify words initialization using Rc::new_zeroed Now that Rc::new_zeroed is stable, remove the cfg(feature = "nightly") branch and the temporary zeroed array on stable. This avoids copying a potentially large [Word; CHUNK_WORDS] into the Rc.
This commit is contained in:
commit
4227404a04
1 changed files with 0 additions and 20 deletions
|
|
@ -634,22 +634,12 @@ impl<T: Idx> ChunkedBitSet<T> {
|
|||
match *chunk {
|
||||
Zeros => {
|
||||
if chunk_domain_size > 1 {
|
||||
#[cfg(feature = "nightly")]
|
||||
let mut words = {
|
||||
// We take some effort to avoid copying the words.
|
||||
let words = Rc::<[Word; CHUNK_WORDS]>::new_zeroed();
|
||||
// SAFETY: `words` can safely be all zeroes.
|
||||
unsafe { words.assume_init() }
|
||||
};
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
let mut words = {
|
||||
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#129396).
|
||||
let words = mem::MaybeUninit::<[Word; CHUNK_WORDS]>::zeroed();
|
||||
// SAFETY: `words` can safely be all zeroes.
|
||||
let words = unsafe { words.assume_init() };
|
||||
// Unfortunate possibly-large copy
|
||||
Rc::new(words)
|
||||
};
|
||||
let words_ref = Rc::get_mut(&mut words).unwrap();
|
||||
|
||||
let (word_index, mask) = chunk_word_index_and_mask(elem);
|
||||
|
|
@ -695,22 +685,12 @@ impl<T: Idx> ChunkedBitSet<T> {
|
|||
Zeros => false,
|
||||
Ones => {
|
||||
if chunk_domain_size > 1 {
|
||||
#[cfg(feature = "nightly")]
|
||||
let mut words = {
|
||||
// We take some effort to avoid copying the words.
|
||||
let words = Rc::<[Word; CHUNK_WORDS]>::new_zeroed();
|
||||
// SAFETY: `words` can safely be all zeroes.
|
||||
unsafe { words.assume_init() }
|
||||
};
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
let mut words = {
|
||||
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#129396).
|
||||
let words = mem::MaybeUninit::<[Word; CHUNK_WORDS]>::zeroed();
|
||||
// SAFETY: `words` can safely be all zeroes.
|
||||
let words = unsafe { words.assume_init() };
|
||||
// Unfortunate possibly-large copy
|
||||
Rc::new(words)
|
||||
};
|
||||
let words_ref = Rc::get_mut(&mut words).unwrap();
|
||||
|
||||
// Set only the bits in use.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue