Commit Graph
18 Commits
Author SHA1 Message Date
Behdad Esfahbod 5bf0cfbc45 [set] Insert coverage intersections by bitmap word
Coverage format 2 now reads intersection results a word at a time, but
still inserted every selected glyph separately. Add an internal
word-at-a-time set insertion path and use it when the output sink is an
hb_set_t, preserving the generic per-glyph fallback for other sinks.

This removes another about 121M instructions from Noto Nastaliq
dependency construction. The compile-only run now takes about 226ms
task-clock / 229ms elapsed and 2.83B instructions, over 2,000x faster
than the original 7:44.77 run.

Dependency graphs match the original output for Noto Nastaliq, Noto
Sans Duployan, Gulzar, Iran Nastaliq, Noto COLRv1, Amiri, and Source
Serif Variable Roman.

Tested with: meson test -C build

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-20 04:04:54 -06:00
Behdad Esfahbod 7951998565 [set] Compute iterator length lazily
Set iteration does not always need the remaining item count. Defer the
population scan until len() is first requested, using unsigned accounting
to track advances without adding a branch to the iterator hot path.

This preserves fast length for iterator consumers that use it while
avoiding unnecessary population scans for the others. Noto Nastaliq
dependency construction is instruction-neutral because its existing set
iterators already encounter cached populations.

Tested with: meson test -C build

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-20 03:55:41 -06:00
Behdad Esfahbod 4daafa0767 [depend] Encode common active glyph states
Root and singleton active-glyph sets dominate dependency recursion memo
keys. Avoid copying and interning the root set, and encode singleton glyph
IDs directly in the key.

Add an internal singleton query that can recognize uncached sparse sets in
one pass while preserving the population cache.

On NotoNastaliqUrdu-Regular.ttf this reduces the compile-only dependency
run from about 3.18B to 3.05B instructions and from about 245ms to 238ms.
Dependency graphs match the previous output across the focused font
corpus.

Tested with: meson test -C build

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-20 03:45:19 -06:00
Behdad Esfahbod 3c55d48206 [set] Iterate over bitmap words
Fetch one nonempty 64-bit bitmap word at a time and consume its bits
locally in hb_set_t iterators. This avoids searching the sparse page
map once per codepoint while preserving inverted-set iteration and
bidirectional iterator behavior.

Mutating a set now explicitly invalidates its iterators.

Noto Nastaliq dependency construction is about 1-2% faster in an A/B
comparison, with 3.33B instructions reduced to 3.31B.

Tests: meson test -C build (272/272)
Tests: Noto dependency graph byte-identical to the pre-change oracle
Tests: full-Unicode subset output byte-identical for Noto Nastaliq,
       Amiri, Source Serif Variable, and Noto COLRv1

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-20 02:45:18 -06:00
Behdad Esfahbod 80529ca839 [set] Add exact set intersection helper
Set-to-set intersection currently only has a conservative may_intersect
helper because sets can be inverted. Callers that know their sets are
not inverted must otherwise reach through two implementation layers.

Add an exact intersects overload that handles all inversion combinations
without allocating. Use it for contextual dependency collection and add
unit coverage for normal, mixed, and inverted pairs.

Tested with the full Meson test suite (270/270 passed).

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-19 15:57:10 -06:00
Behdad Esfahbod 75f919876f [src/test-*] Use hb_always_assert() which isn't compiled out under NDEBUG
Part of https://github.com/harfbuzz/harfbuzz/issues/5418
2025-07-25 03:00:38 -06:00
Behdad Esfahbod ca27925d55 Use hb_codepoint_pair_t in more places 2023-06-03 16:18:15 -06:00
Garret Rieger 8d8bcde8cf [set] don't allow -1 (HB_SET_VALUE_INVALID) to be inserted into a hb_set_t.
Add tests that check all of the addition methods.
2023-03-15 12:10:18 -06:00
Behdad Esfahbod 5153218b41 [set] Add hb_set_is_inverted() 2023-01-05 16:26:41 -07:00
Behdad Esfahbod 14ff747024 [set] Add tests for inverted set range iteration 2023-01-05 16:20:59 -07:00
Behdad Esfahbod 1c612a8541 [test-set] Test sinking range 2022-11-18 18:19:31 -07:00
Behdad Esfahbod 356708e34a [test-set] Test length of iterator 2022-11-18 18:17:34 -07:00
Behdad Esfahbod e0f3cab246 [cplusplus] Add hb-cplusplus.hh
Fixes https://github.com/harfbuzz/harfbuzz/issues/2152
2022-06-02 18:22:05 +01:00
Behdad Esfahbod 7fa580bc4f [map] Fix map copy/move constructors to actually work
Ouch!
2022-05-12 13:05:32 -06:00
Behdad Esfahbod a09dd87ca3 [set] Fix set copy/move constructors to actually work
Ouch!
2022-05-12 12:58:07 -06:00
Behdad Esfahbod a03b9b14c9 [map] Add initializer_list and swap() 2021-11-01 22:45:11 -06:00
Behdad Esfahbod c30f6834d0 [map] Add 5 methods 2021-11-01 22:29:14 -06:00
Behdad Esfahbod dcd18da611 [set] Add standard the 5 standard methods & tests 2021-11-01 20:55:30 -06:00