[subset-cff1] Cache glyph-to-sid-map in the accelerator
Benchmark Time CPU Time Old Time New CPU Old CPU New --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/10 -0.0841 -0.0843 0 0 0 0 BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/64 -0.1305 -0.1305 0 0 0 0 BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/512 -0.1398 -0.1401 1 1 1 1 BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/4096 +0.0382 +0.0380 9 9 9 9 BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/10000 +0.0213 +0.0211 11 11 11 11
This commit is contained in:
parent
72fabef0a4
commit
32dd9810cf
|
@ -483,6 +483,11 @@ struct cff2
|
|||
blob = nullptr;
|
||||
}
|
||||
|
||||
hb_map_t *create_glyph_to_sid_map () const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool is_valid () const { return blob; }
|
||||
|
||||
protected:
|
||||
|
|
|
@ -433,11 +433,13 @@ struct cff_subset_accelerator_t
|
|||
|
||||
~cff_subset_accelerator_t() {
|
||||
hb_blob_destroy (original_blob);
|
||||
hb_map_destroy (glyph_to_sid_map.get_relaxed ());
|
||||
}
|
||||
|
||||
parsed_cs_str_vec_t parsed_charstrings;
|
||||
parsed_cs_str_vec_t parsed_global_subrs;
|
||||
hb_vector_t<parsed_cs_str_vec_t> parsed_local_subrs;
|
||||
mutable hb_atomic_ptr_t<hb_map_t> glyph_to_sid_map = nullptr;
|
||||
|
||||
private:
|
||||
hb_blob_t* original_blob;
|
||||
|
|
|
@ -443,8 +443,17 @@ struct cff_subset_plan {
|
|||
return;
|
||||
}
|
||||
|
||||
bool use_glyph_to_sid_map = plan->num_output_glyphs () > plan->source->get_num_glyphs () / 8.;
|
||||
hb_map_t *glyph_to_sid_map = use_glyph_to_sid_map ? acc.create_glyph_to_sid_map () : nullptr;
|
||||
hb_map_t *glyph_to_sid_map = (plan->accelerator && plan->accelerator->cff_accelerator) ?
|
||||
plan->accelerator->cff_accelerator->glyph_to_sid_map :
|
||||
nullptr;
|
||||
bool created_map = false;
|
||||
if (!glyph_to_sid_map &&
|
||||
((plan->accelerator && plan->accelerator->cff_accelerator) ||
|
||||
plan->num_output_glyphs () > plan->source->get_num_glyphs () / 8.))
|
||||
{
|
||||
created_map = true;
|
||||
glyph_to_sid_map = acc.create_glyph_to_sid_map ();
|
||||
}
|
||||
|
||||
unsigned int glyph;
|
||||
for (glyph = 1; glyph < plan->num_output_glyphs (); glyph++)
|
||||
|
@ -468,8 +477,12 @@ struct cff_subset_plan {
|
|||
last_sid = sid;
|
||||
}
|
||||
|
||||
if (glyph_to_sid_map)
|
||||
hb_map_destroy (glyph_to_sid_map);
|
||||
if (created_map)
|
||||
{
|
||||
if (!(plan->accelerator && plan->accelerator->cff_accelerator) ||
|
||||
!plan->accelerator->cff_accelerator->glyph_to_sid_map.cmpexch (nullptr, glyph_to_sid_map))
|
||||
hb_map_destroy (glyph_to_sid_map);
|
||||
}
|
||||
|
||||
bool two_byte = subset_charset_ranges.complete (glyph);
|
||||
|
||||
|
|
Loading…
Reference in New Issue