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 11d963f

Browse files
Auto merge of #113382 - lqd:test-mcp510, r=<try>
[perf] test MCP510
2 parents 41f2b6b + 2cd24b5 commit 11d963f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎compiler/rustc_index/src/bit_set.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,18 @@ impl<T: Idx> DenseBitSet<T> {
187187
/// Insert `elem`. Returns whether the set has changed.
188188
#[inline]
189189
pub fn insert(&mut self, elem: T) -> bool {
190-
assert!(
190+
debug_assert!(
191191
elem.index() < self.domain_size,
192192
"inserting element at index {} but domain size is {}",
193193
elem.index(),
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 によって変換されたページ (->オリジナル) /