mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use swap_remove when unrooting DOM objects. (#36617)
Profiling from #36609 showed this is an easy win. Ordering of our root list does not matter, so swap_remove is a constant time operation compared to a linear time one that caused memmove to appear in profiles with lots of unrooting. Testing: Existing WPT tests will cover this change. Fixes: Part of #36609. Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
c792e6db7c
commit
fad5447838
1 changed files with 1 additions and 1 deletions
|
@ -412,7 +412,7 @@ impl RootCollection {
|
|||
.rposition(|r| std::ptr::addr_eq(*r as *const (), object as *const ()))
|
||||
{
|
||||
Some(idx) => {
|
||||
roots.remove(idx);
|
||||
roots.swap_remove(idx);
|
||||
},
|
||||
None => panic!("Can't remove a root that was never rooted!"),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue