Correctly adjust the backward reference of the next entry when deleting an entry.
This commit is contained in:
parent
c4960d3c11
commit
9140cbc29e
1 changed files with 13 additions and 10 deletions
|
@ -223,22 +223,25 @@ namespace ts {
|
|||
const entry = this.data[key];
|
||||
delete this.data[key];
|
||||
|
||||
// Adjust the linked list references.
|
||||
const previousElement = entry.previousEntry!;
|
||||
previousElement.nextEntry = entry.nextEntry;
|
||||
// Adjust the linked list references of the neighbor entries.
|
||||
const previousEntry = entry.previousEntry!;
|
||||
previousEntry.nextEntry = entry.nextEntry;
|
||||
if (entry.nextEntry) {
|
||||
entry.nextEntry.previousEntry = previousEntry;
|
||||
}
|
||||
|
||||
// When the deleted entry was the last one, we need to
|
||||
// adust the endElement reference.
|
||||
if (this.linkedListEnd === entry) {
|
||||
this.linkedListEnd = previousEntry;
|
||||
}
|
||||
|
||||
// Adjust the forward reference of the deleted element
|
||||
// in case an iterator still references it.
|
||||
entry.previousEntry = undefined;
|
||||
entry.nextEntry = previousElement;
|
||||
entry.nextEntry = previousEntry;
|
||||
entry.skipNext = true;
|
||||
|
||||
// When the deleted entry was the last one, we need to
|
||||
// adust the endElement reference
|
||||
if (this.linkedListEnd === entry) {
|
||||
this.linkedListEnd = previousElement;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue