From 5a10f3a0551c2e62bc0969fd857033ed53f10943 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Fri, 7 Feb 2020 10:38:27 -0800 Subject: [PATCH] Use vector instead of map during page compaction in hb-set. --- src/hb-set.hh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/hb-set.hh b/src/hb-set.hh index 9c1031f51..048f09933 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -452,21 +452,23 @@ struct hb_set_t void compact (unsigned int length) { - hb_hashmap_t old_index_to_page_map_index; + hb_vector_t old_index_to_page_map_index; + old_index_to_page_map_index.resize(pages.length); + for (uint32_t i = 0; i < old_index_to_page_map_index.length; i++) + old_index_to_page_map_index[i] = 0xFFFFFFFF; - for (unsigned int i = 0; i < length; i++) { - old_index_to_page_map_index.set (page_map[i].index, i); - } + for (uint32_t i = 0; i < length; i++) + old_index_to_page_map_index[page_map[i].index] = i; compact_pages (old_index_to_page_map_index); } - void compact_pages (const hb_hashmap_t& old_index_to_page_map_index) + void compact_pages (const hb_vector_t& old_index_to_page_map_index) { unsigned int write_index = 0; for (unsigned int i = 0; i < pages.length; i++) { - if (!old_index_to_page_map_index.has (i)) continue; + if (old_index_to_page_map_index[i] == 0xFFFFFFFF) continue; if (write_index < i) pages[write_index] = pages[i];