Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Simplify dedup_ref (string interning) (#11)
Browse files Browse the repository at this point in the history
This should be slightly more efficient while also being more
understandable.
  • Loading branch information
morrisonlevi authored Nov 23, 2021
1 parent 6482366 commit e9b9b9c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ddprof-profiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,12 @@ impl<T: Sized + Hash + Eq> DedupExt<T> for IndexSet<T> {
match self.get_index_of(item) {
Some(index) => index,
None => {
assert!(self.insert(item.into()));
self.get_index_of(item)
.expect("value to exist by this point")
let (index, inserted) = self.insert_full(item.into());
// This wouldn't make any sense; the item couldn't be found so
// it was inserted but then it already existed? Screams race-
// -condition to me!
assert!(inserted);
index
}
}
}
Expand Down

0 comments on commit e9b9b9c

Please sign in to comment.