mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-14 17:13:40 +00:00
[subset] Pre-alloc a few maps
This commit is contained in:
parent
7319d0d712
commit
24b069cd53
3 changed files with 16 additions and 3 deletions
|
@ -81,6 +81,11 @@ struct hb_multimap_t
|
|||
return singulars.in_error () || multiples_indices.in_error () || multiples_values.in_error ();
|
||||
}
|
||||
|
||||
void resize (unsigned size)
|
||||
{
|
||||
singulars.resize (size);
|
||||
}
|
||||
|
||||
protected:
|
||||
hb_map_t singulars;
|
||||
hb_map_t multiples_indices;
|
||||
|
|
|
@ -79,6 +79,11 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const
|
|||
post::accelerator_t _post (c->plan->source);
|
||||
|
||||
hb_hashmap_t<hb_bytes_t, uint32_t, true> glyph_name_to_new_index;
|
||||
|
||||
old_new_index_map.resize (num_glyphs);
|
||||
old_gid_new_index_map.resize (num_glyphs);
|
||||
glyph_name_to_new_index.resize (num_glyphs);
|
||||
|
||||
for (hb_codepoint_t new_gid = 0; new_gid < num_glyphs; new_gid++)
|
||||
{
|
||||
hb_codepoint_t old_gid = reverse_glyph_map.get (new_gid);
|
||||
|
@ -86,11 +91,12 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const
|
|||
|
||||
unsigned new_index;
|
||||
const uint32_t *new_index2;
|
||||
if (old_index <= 257) new_index = old_index;
|
||||
if (old_index <= 257)
|
||||
new_index = old_index;
|
||||
else if (old_new_index_map.has (old_index, &new_index2))
|
||||
{
|
||||
new_index = *new_index2;
|
||||
} else {
|
||||
else
|
||||
{
|
||||
hb_bytes_t s = _post.find_glyph_name (old_gid);
|
||||
new_index = glyph_name_to_new_index.get (s);
|
||||
if (new_index == (unsigned)-1)
|
||||
|
|
|
@ -769,6 +769,7 @@ _create_glyph_map_gsub (const hb_set_t* glyph_set_gsub,
|
|||
const hb_map_t* glyph_map,
|
||||
hb_map_t* out)
|
||||
{
|
||||
out->resize (glyph_set_gsub->get_population ());
|
||||
+ hb_iter (glyph_set_gsub)
|
||||
| hb_map ([&] (hb_codepoint_t gid) {
|
||||
return hb_pair_t<hb_codepoint_t, hb_codepoint_t> (gid,
|
||||
|
@ -1130,6 +1131,7 @@ hb_subset_plan_t::hb_subset_plan_t (hb_face_t *face,
|
|||
|
||||
hb_map_t &unicode_to_gid = *codepoint_to_glyph;
|
||||
|
||||
gid_to_unicodes.resize (unicodes.get_population ());
|
||||
for (auto unicode : unicodes)
|
||||
{
|
||||
auto gid = unicode_to_gid[unicode];
|
||||
|
|
Loading…
Add table
Reference in a new issue