Skip to content

Commit c42765a

Browse files
committed
Use elem instead of bit consistently for arguments.
1 parent b80cb47 commit c42765a

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/librustc_data_structures/bit_set.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,21 @@ impl<T: Idx> BitSet<T> {
6161
}
6262

6363
/// Sets all elements up to and including `size`.
64-
pub fn set_up_to(&mut self, bit: usize) {
64+
pub fn set_up_to(&mut self, elem: usize) {
6565
for word in &mut self.words {
6666
*word = !0;
6767
}
68-
self.clear_above(bit);
68+
self.clear_above(elem);
6969
}
7070

71-
/// Clear all elements above `bit`.
72-
fn clear_above(&mut self, bit: usize) {
73-
let first_clear_block = bit / WORD_BITS;
71+
/// Clear all elements above `elem`.
72+
fn clear_above(&mut self, elem: usize) {
73+
let first_clear_block = elem / WORD_BITS;
7474

7575
if first_clear_block < self.words.len() {
76-
// Within `first_clear_block`, the `bit % WORD_BITS` LSBs should
76+
// Within `first_clear_block`, the `elem % WORD_BITS` LSBs should
7777
// remain.
78-
let mask = (1 << (bit % WORD_BITS)) - 1;
78+
let mask = (1 << (elem % WORD_BITS)) - 1;
7979
self.words[first_clear_block] &= mask;
8080

8181
// All the blocks above `first_clear_block` are fully cleared.
@@ -96,10 +96,10 @@ impl<T: Idx> BitSet<T> {
9696
self.words.iter().map(|e| e.count_ones() as usize).sum()
9797
}
9898

99-
/// True if `self` contains the bit `bit`.
99+
/// True if `self` contains `elem`.
100100
#[inline]
101-
pub fn contains(&self, bit: T) -> bool {
102-
let (word_index, mask) = word_index_and_mask(bit);
101+
pub fn contains(&self, elem: T) -> bool {
102+
let (word_index, mask) = word_index_and_mask(elem);
103103
(self.words[word_index] & mask) != 0
104104
}
105105

@@ -118,10 +118,10 @@ impl<T: Idx> BitSet<T> {
118118
self.words.iter().all(|a| *a == 0)
119119
}
120120

121-
/// Insert a bit. Returns true if the bit has changed.
121+
/// Insert `elem`. Returns true if the set has changed.
122122
#[inline]
123-
pub fn insert(&mut self, bit: T) -> bool {
124-
let (word_index, mask) = word_index_and_mask(bit);
123+
pub fn insert(&mut self, elem: T) -> bool {
124+
let (word_index, mask) = word_index_and_mask(elem);
125125
let word_ref = &mut self.words[word_index];
126126
let word = *word_ref;
127127
let new_word = word | mask;
@@ -136,10 +136,10 @@ impl<T: Idx> BitSet<T> {
136136
}
137137
}
138138

139-
/// Returns true if the bit has changed.
139+
/// Returns true if the set has changed.
140140
#[inline]
141-
pub fn remove(&mut self, bit: T) -> bool {
142-
let (word_index, mask) = word_index_and_mask(bit);
141+
pub fn remove(&mut self, elem: T) -> bool {
142+
let (word_index, mask) = word_index_and_mask(elem);
143143
let word_ref = &mut self.words[word_index];
144144
let word = *word_ref;
145145
let new_word = word & !mask;
@@ -547,16 +547,16 @@ impl<T: Idx> GrowableBitSet<T> {
547547
GrowableBitSet { bit_set: BitSet::new_empty(bits) }
548548
}
549549

550-
/// Returns true if the bit has changed.
550+
/// Returns true if the set has changed.
551551
#[inline]
552-
pub fn insert(&mut self, bit: T) -> bool {
553-
self.grow(bit);
554-
self.bit_set.insert(bit)
552+
pub fn insert(&mut self, elem: T) -> bool {
553+
self.grow(elem);
554+
self.bit_set.insert(elem)
555555
}
556556

557557
#[inline]
558-
pub fn contains(&self, bit: T) -> bool {
559-
let (word_index, mask) = word_index_and_mask(bit);
558+
pub fn contains(&self, elem: T) -> bool {
559+
let (word_index, mask) = word_index_and_mask(elem);
560560
if let Some(word) = self.bit_set.words.get(word_index) {
561561
(word & mask) != 0
562562
} else {

0 commit comments

Comments
 (0)