[subset] minor on _subset

This commit is contained in:
Ebrahim Byagowi 2020-02-05 15:02:20 +03:30
parent dcb5dfc970
commit 43016715e1
1 changed files with 14 additions and 18 deletions

View File

@ -51,20 +51,16 @@
#include "hb-ot-var-hvar-table.hh"
HB_UNUSED static inline unsigned int
_plan_estimate_subset_table_size (hb_subset_plan_t *plan,
unsigned int table_len);
static inline unsigned int
_plan_estimate_subset_table_size (hb_subset_plan_t *plan,
unsigned int table_len)
static unsigned
_plan_estimate_subset_table_size (hb_subset_plan_t *plan, unsigned table_len)
{
unsigned int src_glyphs = plan->source->get_num_glyphs ();
unsigned int dst_glyphs = plan->glyphset ()->get_population ();
unsigned src_glyphs = plan->source->get_num_glyphs ();
unsigned dst_glyphs = plan->glyphset ()->get_population ();
if (unlikely (!src_glyphs))
return 512 + table_len;
return 512 + (unsigned int) (table_len * sqrt ((double) dst_glyphs / src_glyphs));
return 512 + (unsigned) (table_len * sqrt ((double) dst_glyphs / src_glyphs));
}
template<typename TableType>
@ -81,7 +77,7 @@ _subset (hb_subset_plan_t *plan)
hb_vector_t<char> buf;
/* TODO Not all tables are glyph-related. 'name' table size for example should not be
* affected by number of glyphs. Accommodate that. */
unsigned int buf_size = _plan_estimate_subset_table_size (plan, source_blob->length);
unsigned buf_size = _plan_estimate_subset_table_size (plan, source_blob->length);
DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
if (unlikely (!buf.alloc (buf_size)))
{