Skip to content

Commit

Permalink
Don't shadow raw_bucket variables
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Jun 25, 2020
1 parent 3c95c02 commit b918c88
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/map_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,18 @@ impl<K, V> IndexMapCore<K, V> {
if shifted_entries.len() > raw_capacity / 2 {
// shift all indices greater than `index`
unsafe {
for raw_bucket in self.indices.iter() {
let i = raw_bucket.read();
for bucket in self.indices.iter() {
let i = bucket.read();
if i > index {
raw_bucket.write(i - 1);
bucket.write(i - 1);
}
}
}
} else {
// find each following entry to shift its index
for (i, entry) in (index + 1..).zip(shifted_entries) {
let raw_bucket = self.find_index(entry.hash, i).unwrap();
unsafe { raw_bucket.write(i - 1) };
let shifted_bucket = self.find_index(entry.hash, i).unwrap();
unsafe { shifted_bucket.write(i - 1) };
}
}

Expand Down Expand Up @@ -336,8 +336,8 @@ impl<K, V> IndexMapCore<K, V> {
// was not last element
// examine new element in `index` and find it in indices
let last = self.entries.len();
let raw_bucket = self.find_index(entry.hash, last).unwrap();
unsafe { raw_bucket.write(index) };
let swapped_bucket = self.find_index(entry.hash, last).unwrap();
unsafe { swapped_bucket.write(index) };
}

(index, entry.key, entry.value)
Expand Down

0 comments on commit b918c88

Please sign in to comment.