mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 22:10:29 +00:00
perf: introduce CFReleaseThread for running CoreFoundation releases
Some CoreFoundation objects, such as those produced by CoreText, have expensive callbacks that run when they are released. By offloading the CFRelease calls to another thread, we can avoid important threads being blocked by unexpectedly expensive callbacks. This commit also changes the way that the coretext shaper's run iterator builds its string. Rather than using a CFMutableString, an ArrayList of unichars is built which is passed to CFStringCreateWithCharactersNoCopy, which is a lot more efficient since it avoids all the CoreFoundation overhead.
This commit is contained in:
@@ -19,6 +19,17 @@ pub const String = opaque {
|
||||
)))) orelse Allocator.Error.OutOfMemory;
|
||||
}
|
||||
|
||||
pub fn createWithCharactersNoCopy(
|
||||
unichars: []const u16,
|
||||
) *String {
|
||||
return @as(*String, @ptrFromInt(@intFromPtr(c.CFStringCreateWithCharactersNoCopy(
|
||||
null,
|
||||
@ptrCast(unichars.ptr),
|
||||
@intCast(unichars.len),
|
||||
foundation.c.kCFAllocatorNull,
|
||||
))));
|
||||
}
|
||||
|
||||
pub fn release(self: *String) void {
|
||||
c.CFRelease(self);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user