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

View File

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