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
Optimize Cache Growth Strategy
Current CACHE_STEP is fixed at 192. Use exponential growth to reduce reallocations:
// CURRENT:
#define CACHE_STEP 192
cacheSize = newLength;
glyphCache = realloc(glyphCache, sizeof(GlyphCacheEntry) * cacheSize);
// PROPOSED:
if (cacheSize < newLength) {
cacheSize = MAX(newLength, cacheSize * 2); // Exponential growth
cacheSize = MAX(cacheSize, 64); // Minimum allocation
glyphCache = realloc(glyphCache, sizeof(GlyphCacheEntry) * cacheSize);
}
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
Optimize Cache Growth Strategy
Current
CACHE_STEPis fixed at 192. Use exponential growth to reduce reallocations: