Skip to content

GSHorizontalTypesetter improvements: Optimize Cache Growth Strategy #408

Description

@IOOI-SqAR

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions