I asked the Kimi AI how to further improve GSHorizontalTypesetter. Here is what it came up with:
https://www.kimi.com/share/19d34cdb-8242-8fc9-8000-00001fd46e3b
Add Fast Path for Simple Rectangular Containers
The TODO comment mentions this optimization. For the common case of a simple rectangular text container without exclusion paths, bypass the expensive line fragment rect building:
- (BOOL) _useSimpleRectangularLayout: (NSRect)proposedRect
lineHeight: (CGFloat)lineHeight
{
if (![currentTextContainer isSimpleRectangularTextContainer])
return NO;
NSSize containerSize = [currentTextContainer containerSize];
NSRect simpleRect = proposedRect;
// Single rectangle for the entire width
if (lineFragmentCount == 0) {
lineFragmentCapacity = MAX(lineFragmentCapacity, 2);
lineFragments = realloc(lineFragments, sizeof(LineFragment) * lineFragmentCapacity);
}
lineFragments[0].rect = simpleRect;
lineFragmentCount = 1;
// Skip the expensive lineFragmentRectForProposedRect: loop
return YES;
}
I would say we should address this after fixing the line wrap bug first (has been #382 which is closed now (but the issue is not fixed yet))
I asked the Kimi AI how to further improve GSHorizontalTypesetter. Here is what it came up with:
https://www.kimi.com/share/19d34cdb-8242-8fc9-8000-00001fd46e3b
Add Fast Path for Simple Rectangular Containers
The TODO comment mentions this optimization. For the common case of a simple rectangular text container without exclusion paths, bypass the expensive line fragment rect building:
I would say we should address this after fixing the line wrap bug first (has been #382 which is closed now (but the issue is not fixed yet))