[depend] Combine edge deduplication lookup and insert

Use a non-overwriting hashmap insertion to detect duplicate dependency
edges. This avoids hashing and probing every newly inserted edge twice,
while still distinguishing duplicates from allocation failures through
the hashmap error state.

The NotoNastaliqUrdu compile-only dependency workload saves about 2.2M
instructions. Its wall-time change is below measurement noise.

Tested with: meson test -C build

Assisted-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
Behdad Esfahbod committed 2026-08-20 03:48:08 -06:00
1 parent 4daafa0767
commit 375b3f4b33
1 file changed
+2 -5
+2 -5
View File
@@ -470,11 +470,8 @@ struct hb_depend_data_builder_t
}
hb_depend_edge_key_t key (target, table_tag, layout_tag, dependent, lig_set, context_set);
if (seen_edges.has (key))
return false;
if (unlikely (!seen_edges.set (key, true)))
return fail ();
if (!seen_edges.set (key, true, false))
return unlikely (seen_edges.in_error ()) ? fail () : false;
auto &gdr = data.glyph_dependencies[target];
if (unlikely (!gdr.dependencies.push_or_fail (table_tag, dependent, layout_tag,