mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Issue #1861 - Cache the most recent nsGenConNode to speed up future insertions.
Cache the most recent nsGenConNode to speed up future insertions.
This commit is contained in:
parent
6c1c2339bc
commit
c0591cb147
2 changed files with 16 additions and 1 deletions
|
|
@ -19,6 +19,7 @@ nsGenConList::Clear()
|
|||
delete node;
|
||||
}
|
||||
mSize = 0;
|
||||
mLastInserted = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -41,6 +42,9 @@ nsGenConList::DestroyNodesFor(nsIFrame* aFrame)
|
|||
node = nextNode;
|
||||
}
|
||||
|
||||
// Modification of the list invalidates the cached pointer.
|
||||
mLastInserted = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -108,6 +112,11 @@ nsGenConList::Insert(nsGenConNode* aNode)
|
|||
// Check for append.
|
||||
if (mList.isEmpty() || NodeAfter(aNode, mList.getLast())) {
|
||||
mList.insertBack(aNode);
|
||||
} else if (mLastInserted && mLastInserted != mList.getLast() &&
|
||||
NodeAfter(aNode, mLastInserted) &&
|
||||
NodeAfter(Next(mLastInserted), aNode)) {
|
||||
// Fast path for inserting many consecutive nodes in one place
|
||||
mLastInserted->setNext(aNode);
|
||||
} else {
|
||||
// Binary search.
|
||||
|
||||
|
|
@ -142,6 +151,8 @@ nsGenConList::Insert(nsGenConNode* aNode)
|
|||
}
|
||||
++mSize;
|
||||
|
||||
mLastInserted = aNode;
|
||||
|
||||
// Set the mapping only if it is the first node of the frame.
|
||||
// The DEBUG blocks below are for ensuring the invariant required by
|
||||
// nsGenConList::DestroyNodesFor. See comment there.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue