mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 06:21:16 +01:00
[depend] Retain active glyph set storage
Dependency recursion moves each position glyph set onto the active stack. Popping the stack then destroys the set and its backing pages, so the next edge has to allocate them again. Keep constructed stack slots and track the active depth separately. Reused slots are cleared before use, preserving the previous empty-set semantics while retaining their allocations across sibling traversals. After contextual scratch pooling, this reduces Noto Nastaliq dependency compilation from about 294ms to 277ms. Allocation calls fall from 1.19 million to 371 thousand, and cumulative allocated bytes fall from 163MB to 80MB. Serialized output remains byte-identical. Tests: meson test -C build (272/272) Assisted-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
1 parent
de89b1a490
commit
8940e7050b
1 file changed
+11
-6
@@ -484,25 +484,29 @@ struct hb_depend_context_t :
|
||||
|
||||
const hb_set_t& parent_active_glyphs ()
|
||||
{
|
||||
if (!active_glyphs_stack)
|
||||
if (!active_glyphs_stack_depth)
|
||||
return *glyphs;
|
||||
|
||||
return active_glyphs_stack.tail ();
|
||||
return active_glyphs_stack[active_glyphs_stack_depth - 1];
|
||||
}
|
||||
|
||||
hb_set_t* push_cur_active_glyphs ()
|
||||
{
|
||||
if (unlikely (!active_glyphs_stack.push_or_fail ()))
|
||||
if (active_glyphs_stack_depth == active_glyphs_stack.length &&
|
||||
unlikely (!active_glyphs_stack.push_or_fail ()))
|
||||
return nullptr;
|
||||
return &active_glyphs_stack.tail ();
|
||||
|
||||
hb_set_t *set = &active_glyphs_stack[active_glyphs_stack_depth++];
|
||||
set->clear ();
|
||||
return set;
|
||||
}
|
||||
|
||||
bool pop_cur_done_glyphs ()
|
||||
{
|
||||
if (!active_glyphs_stack)
|
||||
if (!active_glyphs_stack_depth)
|
||||
return false;
|
||||
|
||||
active_glyphs_stack.pop ();
|
||||
active_glyphs_stack_depth--;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -627,6 +631,7 @@ struct hb_depend_context_t :
|
||||
hb_face_t *face;
|
||||
hb_set_t *glyphs;
|
||||
hb_vector_t<hb_set_t> active_glyphs_stack;
|
||||
unsigned active_glyphs_stack_depth = 0;
|
||||
recurse_func_t recurse_func;
|
||||
hb_codepoint_t lookup_index = HB_CODEPOINT_INVALID;
|
||||
hb_set_t lookups_seen;
|
||||
|
||||
Reference in new issue
Block a user