Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b2dbbb6

Browse files
committed
densebitset-unsafe wip
1 parent b2dd217 commit b2dbbb6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎compiler/rustc_index/src/bit_set.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ impl<T: Idx> DenseBitSet<T> {
194194
self.domain_size,
195195
);
196196
let (word_index, mask) = word_index_and_mask(elem);
197-
let word_ref = &mut self.words[word_index];
197+
// SAFETY:
198+
// The number of words we have is the domain size divided by word size (rounded up). We have
199+
// asserted above that the element is contained within the domain size. Therefore,
200+
// word_index is in bounds.
201+
let word_ref = unsafe { self.words.get_unchecked_mut(word_index) };
198202
let word = *word_ref;
199203
let new_word = word | mask;
200204
*word_ref = new_word;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /