Micro-optimize display link callback

Use a GCD block rather than a runtime selector with a boxed number
This commit is contained in:
Kovid Goyal 2025-10-22 13:35:02 +05:30
parent 26ea343f95
commit 6a6b0b47a3
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 12 deletions

View file

@ -84,11 +84,9 @@
CGDirectDisplayID displayID = entry->displayID;
if (should_dispatch) entry->pending_dispatch = true;
os_unfair_lock_unlock(lock);
if (should_dispatch) {
NSNumber *arg = [NSNumber numberWithUnsignedInt:displayID];
[NSApp performSelectorOnMainThread:@selector(render_frame_received:) withObject:arg waitUntilDone:NO];
[arg release];
}
if (should_dispatch) dispatch_async(dispatch_get_main_queue(), ^{
_glfwDispatchRenderFrame(displayID);
});
}
return kCVReturnSuccess;
}

View file

@ -500,7 +500,6 @@ - (void)applicationDidHide:(NSNotification *)notification
@interface GLFWApplication : NSApplication
- (void)tick_callback;
- (void)render_frame_received:(id)displayIDAsID;
@end
@implementation GLFWApplication
@ -509,12 +508,6 @@ - (void)tick_callback
_glfwDispatchTickCallback();
}
- (void)render_frame_received:(id)displayIDAsID
{
CGDirectDisplayID displayID = [(NSNumber*)displayIDAsID unsignedIntValue];
_glfwDispatchRenderFrame(displayID);
}
@end