Remove insert_noop.
Because it's as useless as its name suggests. This commit also renames `UndoLog::Noop` as `UndoLog::Purged`, because (a) that's a more descriptive name and (b) it matches the name used in similar code in `librustc/infer/region_constraints/mod.rs`.
This commit is contained in:
parent
1e34dfce6f
commit
9847b5cfcb
2 changed files with 6 additions and 16 deletions
|
|
@ -1714,12 +1714,8 @@ impl<'tcx> ProjectionCache<'tcx> {
|
|||
/// to be a NormalizedTy.
|
||||
pub fn complete_normalized(&mut self, key: ProjectionCacheKey<'tcx>, ty: &NormalizedTy<'tcx>) {
|
||||
// We want to insert `ty` with no obligations. If the existing value
|
||||
// already has no obligations (as is common) we can use `insert_noop`
|
||||
// to do a minimal amount of work -- the HashMap insertion is skipped,
|
||||
// and minimal changes are made to the undo log.
|
||||
if ty.obligations.is_empty() {
|
||||
self.map.insert_noop();
|
||||
} else {
|
||||
// already has no obligations (as is common) we don't insert anything.
|
||||
if !ty.obligations.is_empty() {
|
||||
self.map.insert(key, ProjectionCacheEntry::NormalizedTy(Normalized {
|
||||
value: ty.value,
|
||||
obligations: vec![]
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ enum UndoLog<K, V> {
|
|||
CommittedSnapshot,
|
||||
Inserted(K),
|
||||
Overwrite(K, V),
|
||||
Noop,
|
||||
Purged,
|
||||
}
|
||||
|
||||
impl<K, V> SnapshotMap<K, V>
|
||||
|
|
@ -72,12 +72,6 @@ impl<K, V> SnapshotMap<K, V>
|
|||
}
|
||||
}
|
||||
|
||||
pub fn insert_noop(&mut self) {
|
||||
if !self.undo_log.is_empty() {
|
||||
self.undo_log.push(UndoLog::Noop);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, key: K) -> bool {
|
||||
match self.map.remove(&key) {
|
||||
Some(old_value) => {
|
||||
|
|
@ -128,13 +122,13 @@ impl<K, V> SnapshotMap<K, V>
|
|||
let reverse = match self.undo_log[i] {
|
||||
UndoLog::OpenSnapshot => false,
|
||||
UndoLog::CommittedSnapshot => false,
|
||||
UndoLog::Noop => false,
|
||||
UndoLog::Purged => false,
|
||||
UndoLog::Inserted(ref k) => should_revert_key(k),
|
||||
UndoLog::Overwrite(ref k, _) => should_revert_key(k),
|
||||
};
|
||||
|
||||
if reverse {
|
||||
let entry = mem::replace(&mut self.undo_log[i], UndoLog::Noop);
|
||||
let entry = mem::replace(&mut self.undo_log[i], UndoLog::Purged);
|
||||
self.reverse(entry);
|
||||
}
|
||||
}
|
||||
|
|
@ -171,7 +165,7 @@ impl<K, V> SnapshotMap<K, V>
|
|||
self.map.insert(key, old_value);
|
||||
}
|
||||
|
||||
UndoLog::Noop => {}
|
||||
UndoLog::Purged => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue