mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 00:49:46 +00:00
LibJS+LibWeb: Use GC::Weak instead of AK::WeakPtr for GC-allocated types
This makes some common types like JS::Object smaller (by 8 bytes) and yields a minor speed improvement on many benchmarks.
This commit is contained in:
parent
25a5ed94d6
commit
dfa796a4e4
Notes:
github-actions[bot]
2025-10-17 15:25:08 +00:00
Author: https://github.com/awesomekling
Commit: dfa796a4e4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6496
36 changed files with 111 additions and 115 deletions
|
|
@ -10,17 +10,17 @@ namespace Web::DOM {
|
|||
|
||||
void ElementByIdMap::add(FlyString const& element_id, Element& element)
|
||||
{
|
||||
auto& elements_with_id = m_map.ensure(element_id, [] { return Vector<WeakPtr<Element>> {}; });
|
||||
auto& elements_with_id = m_map.ensure(element_id, [] { return Vector<GC::Weak<Element>> {}; });
|
||||
|
||||
// Remove all elements that were deallocated.
|
||||
elements_with_id.remove_all_matching([](WeakPtr<Element>& element) {
|
||||
return !element.has_value();
|
||||
elements_with_id.remove_all_matching([](GC::Weak<Element>& element) {
|
||||
return !element;
|
||||
});
|
||||
|
||||
elements_with_id.remove_first_matching([&](auto const& another_element) {
|
||||
return &element == another_element.ptr();
|
||||
});
|
||||
elements_with_id.insert_before_matching(element, [&](auto& another_element) {
|
||||
elements_with_id.insert_before_matching(GC::Weak<Element> { element }, [&](auto& another_element) {
|
||||
return element.is_before(*another_element);
|
||||
});
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ void ElementByIdMap::remove(FlyString const& element_id, Element& element)
|
|||
return;
|
||||
auto& elements_with_id = *maybe_elements_with_id;
|
||||
elements_with_id.remove_all_matching([&](auto& another_element) {
|
||||
if (!another_element.has_value())
|
||||
if (!another_element)
|
||||
return true;
|
||||
return &element == another_element.ptr();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue