Cleanups in hb-subset-glyf and hb-subset-plan.

This commit is contained in:
Garret Rieger 2018-02-07 16:30:07 -08:00 committed by Behdad Esfahbod
parent 13193a9b97
commit 217ed5e3c8
2 changed files with 16 additions and 16 deletions

View File

@ -30,7 +30,7 @@
#include "hb-subset-glyf.hh" #include "hb-subset-glyf.hh"
bool bool
calculate_glyf_prime_size (const OT::glyf::accelerator_t &glyf, _calculate_glyf_prime_size (const OT::glyf::accelerator_t &glyf,
hb_set_t *glyph_ids, hb_set_t *glyph_ids,
unsigned int *size /* OUT */) unsigned int *size /* OUT */)
{ {
@ -38,7 +38,7 @@ calculate_glyf_prime_size (const OT::glyf::accelerator_t &glyf,
hb_codepoint_t next_glyph = -1; hb_codepoint_t next_glyph = -1;
while (hb_set_next(glyph_ids, &next_glyph)) { while (hb_set_next(glyph_ids, &next_glyph)) {
unsigned int start_offset, end_offset; unsigned int start_offset, end_offset;
if (!glyf.get_offsets (next_glyph, &start_offset, &end_offset)) { if (unlikely (!glyf.get_offsets (next_glyph, &start_offset, &end_offset))) {
*size = 0; *size = 0;
return false; return false;
} }
@ -51,7 +51,7 @@ calculate_glyf_prime_size (const OT::glyf::accelerator_t &glyf,
} }
bool bool
write_glyf_prime (const OT::glyf::accelerator_t &glyf, _write_glyf_prime (const OT::glyf::accelerator_t &glyf,
const char *glyf_data, const char *glyf_data,
hb_set_t *glyph_ids, hb_set_t *glyph_ids,
int glyf_prime_size, int glyf_prime_size,
@ -62,7 +62,7 @@ write_glyf_prime (const OT::glyf::accelerator_t &glyf,
hb_codepoint_t next_glyph = -1; hb_codepoint_t next_glyph = -1;
while (hb_set_next(glyph_ids, &next_glyph)) { while (hb_set_next(glyph_ids, &next_glyph)) {
unsigned int start_offset, end_offset; unsigned int start_offset, end_offset;
if (!glyf.get_offsets (next_glyph, &start_offset, &end_offset)) { if (unlikely (!glyf.get_offsets (next_glyph, &start_offset, &end_offset))) {
return false; return false;
} }
@ -85,15 +85,15 @@ _hb_subset_glyf (const OT::glyf::accelerator_t &glyf,
// TODO(grieger): Subset loca simultaneously. // TODO(grieger): Subset loca simultaneously.
unsigned int glyf_prime_size; unsigned int glyf_prime_size;
if (!calculate_glyf_prime_size (glyf, if (unlikely (!_calculate_glyf_prime_size (glyf,
glyphs_to_retain, glyphs_to_retain,
&glyf_prime_size)) { &glyf_prime_size))) {
return false; return false;
} }
char *glyf_prime_data = (char *) calloc (glyf_prime_size, 1); char *glyf_prime_data = (char *) calloc (glyf_prime_size, 1);
if (!write_glyf_prime (glyf, glyf_data, glyphs_to_retain, glyf_prime_size, if (unlikely (!_write_glyf_prime (glyf, glyf_data, glyphs_to_retain, glyf_prime_size,
glyf_prime_data)) { glyf_prime_data))) {
free (glyf_prime_data); free (glyf_prime_data);
return false; return false;
} }

View File

@ -55,4 +55,4 @@ hb_subset_plan_get_empty ();
void void
hb_subset_plan_destroy (hb_subset_plan_t *plan); hb_subset_plan_destroy (hb_subset_plan_t *plan);
#endif /* HB_SUBSET_PLAN_PRIVATE_HH */ #endif /* HB_SUBSET_PLAN_HH */