@@ -252,22 +252,31 @@ impl RenderThread {
252
252
// Handle initial control messages
253
253
self . handle_control_messages ( ) ;
254
254
255
- for quantum in 0 ..num_frames {
256
- // Suspend at given times and run callbacks
257
- if suspend_callbacks. first ( ) . map ( |& ( q, _) | q) == Some ( quantum) {
258
- let callback = suspend_callbacks. remove ( 0 ) . 1 ;
259
- ( callback) ( context) ;
260
-
261
- // Handle any control messages that may have been submitted by the callback
262
- self . handle_control_messages ( ) ;
255
+ // Fast path when
256
+ // - no suspensions scheduled
257
+ // - no script processor (so no event handling needed during rendering)
258
+ if suspend_callbacks. is_empty ( ) {
259
+ for _ in 0 ..num_frames {
260
+ self . render_offline_quantum ( & mut buffer) ;
263
261
}
262
+ } else {
263
+ for quantum in 0 ..num_frames {
264
+ // Suspend at given times and run callbacks
265
+ if suspend_callbacks. first ( ) . map ( |& ( q, _) | q) == Some ( quantum) {
266
+ let callback = suspend_callbacks. remove ( 0 ) . 1 ;
267
+ ( callback) ( context) ;
268
+
269
+ // Handle any control messages that may have been submitted by the callback
270
+ self . handle_control_messages ( ) ;
271
+ }
264
272
265
- self . render_offline_quantum ( & mut buffer) ;
273
+ self . render_offline_quantum ( & mut buffer) ;
266
274
267
- let events_were_handled = event_loop. handle_pending_events ( ) ;
268
- if events_were_handled {
269
- // Handle any control messages that may have been submitted by the handler
270
- self . handle_control_messages ( ) ;
275
+ let events_were_handled = event_loop. handle_pending_events ( ) ;
276
+ if events_were_handled {
277
+ // Handle any control messages that may have been submitted by the handler
278
+ self . handle_control_messages ( ) ;
279
+ }
271
280
}
272
281
}
273
282
0 commit comments