Skip to content

Commit ada8d63

Browse files
committed
Simplify the control flow of VacantEntry insertion
1 parent a18fd8d commit ada8d63

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ pub struct VacantEntry<'a, K: 'a, V: 'a, S: 'a = RandomState> {
437437
probe: usize,
438438
#[allow(dead_code)]
439439
index: usize,
440-
stealing_bucket: bool,
441440
}
442441

443442
impl<'a, K, V, S> VacantEntry<'a, K, V, S> {
@@ -456,12 +455,8 @@ impl<'a, K, V, S> VacantEntry<'a, K, V, S> {
456455
{
457456
let index = self.map.entries.len();
458457
self.map.entries.push(Bucket { hash: self.hash, key: self.key, value: value });
459-
if self.stealing_bucket {
460-
let old_pos = Pos::with_hash::<Sz>(index, self.hash);
461-
self.map.insert_phase_2::<Sz>(self.probe, old_pos);
462-
} else {
463-
self.map.indices[self.probe] = Pos::with_hash::<Sz>(index, self.hash);
464-
}
458+
let old_pos = Pos::with_hash::<Sz>(index, self.hash);
459+
self.map.insert_phase_2::<Sz>(self.probe, old_pos);
465460
&mut {self.map}.entries[index].value
466461
}
467462
}
@@ -508,7 +503,6 @@ impl<K, V, S> OrderMap<K, V, S>
508503
hash: hash,
509504
key: key,
510505
probe: probe,
511-
stealing_bucket: true,
512506
index: i,
513507
});
514508
} else if entry_hash == hash && self.entries[i].key == key {
@@ -527,7 +521,6 @@ impl<K, V, S> OrderMap<K, V, S>
527521
hash: hash,
528522
key: key,
529523
probe: probe,
530-
stealing_bucket: false,
531524
index: 0,
532525
});
533526
}

0 commit comments

Comments
 (0)