mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
script: Skip RAII guard and early return when input event queue is empty (#43301)
This is a hot path: - there is a lot of processing in `handle_pending_input_events`: JS realm entry, temporary variable creation, value assignment etc. - we acquire a RAII guard before calling the function. If the event queue is empty, this would result in unnecessary overhead on the hot path. We skip all above work in this case. Testing: This is an optimization that should not change visible behaviour, thus covered by all the testdriver tests. --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
@@ -1092,6 +1092,9 @@ impl ScriptThread {
|
||||
warn!("Input event sent to a pipeline with a closed window {pipeline_id}.");
|
||||
return;
|
||||
}
|
||||
if !document.event_handler().has_pending_input_events() {
|
||||
return;
|
||||
}
|
||||
|
||||
let _guard = ScriptUserInteractingGuard::new(self.is_user_interacting.clone());
|
||||
document.event_handler().handle_pending_input_events(can_gc);
|
||||
|
||||
Reference in New Issue
Block a user