mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-05 01:10:24 +00:00
LibCore: Avoid excessive ref-count churn in event dispatch
We were strongly reffing the event receiver twice before actually invoking the event handlers.
This commit is contained in:
committed by
Andreas Kling
parent
fa85f62895
commit
23fb9781d1
Notes:
github-actions[bot]
2025-12-03 12:27:58 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/23fb9781d1c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7004
@@ -102,15 +102,11 @@ size_t ThreadEventQueue::process()
|
||||
size_t processed_events = 0;
|
||||
for (size_t i = 0; i < events.size(); ++i) {
|
||||
auto& queued_event = events.at(i);
|
||||
auto receiver = queued_event.receiver.strong_ref();
|
||||
auto& event = *queued_event.event;
|
||||
|
||||
if (event.type() == Event::Type::DeferredInvoke) {
|
||||
static_cast<DeferredInvocationEvent&>(event).m_invokee();
|
||||
} else if (!receiver) {
|
||||
// Receiver disappeared, drop the event on the floor.
|
||||
} else {
|
||||
NonnullRefPtr<EventReceiver> protector(*receiver);
|
||||
} else if (auto receiver = queued_event.receiver.strong_ref()) {
|
||||
receiver->dispatch_event(event);
|
||||
}
|
||||
++processed_events;
|
||||
|
||||
Reference in New Issue
Block a user