mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibJS: Visit WeakMap's values as long as their keys were not collected
While the WeakMap only holds a weak reference to its keys, their accompanying values should be kept alive as long as they're accessible.
This commit is contained in:
parent
073a1dec16
commit
b92871f7ef
Notes:
sideshowbarker
2024-07-19 01:59:31 +09:00
Author: https://github.com/IdanHo
Commit: b92871f7ef
Pull-request: https://github.com/SerenityOS/serenity/pull/9969
Reviewed-by: https://github.com/awesomekling ✅
Reviewed-by: https://github.com/linusg
2 changed files with 8 additions and 0 deletions
|
@ -29,4 +29,11 @@ void WeakMap::remove_swept_cells(Badge<Heap>, Span<Cell*> cells)
|
|||
m_values.remove(cell);
|
||||
}
|
||||
|
||||
void WeakMap::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
for (auto& entry : m_values)
|
||||
visitor.visit(entry.value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue