From d7e2a51de2fb6c18c05bbc4c270efb01e9d744e1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 11 Feb 2021 10:55:03 -0700 Subject: [PATCH] [minor] Add unlikely() when checking for error --- src/hb-face.cc | 2 +- src/hb-ot-glyf-table.hh | 2 +- src/hb-ot-layout-gsubgpos.hh | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hb-face.cc b/src/hb-face.cc index a15687c19..900014fae 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -756,7 +756,7 @@ hb_face_builder_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob) hb_face_builder_data_t *data = (hb_face_builder_data_t *) face->user_data; hb_face_builder_data_t::table_entry_t *entry = data->tables.push (); - if (data->tables.in_error()) + if (unlikely (data->tables.in_error())) return false; entry->tag = tag; diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 5470bd96d..ec77c2b43 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -186,7 +186,7 @@ struct glyf | hb_map (&SubsetGlyph::padded_size) ; - if (c->serializer->in_error ()) return_trace (false); + if (unlikely (c->serializer->in_error ())) return_trace (false); return_trace (c->serializer->check_success (_add_loca_and_head (c->plan, padded_offsets))); } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 101d03e90..82ef69412 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -89,7 +89,7 @@ struct hb_closure_context_t : bool is_lookup_done (unsigned int lookup_index) { - if (done_lookups->in_error ()) + if (unlikely (done_lookups->in_error ())) return true; /* Have we visited this lookup with the current set of glyphs? */ @@ -162,10 +162,10 @@ struct hb_closure_lookups_context_t : bool is_lookup_visited (unsigned lookup_index) { - if (lookup_count++ > HB_MAX_LOOKUP_INDICES) + if (unlikely (lookup_count++ > HB_MAX_LOOKUP_INDICES)) return true; - if (visited_lookups->in_error ()) + if (unlikely (visited_lookups->in_error ())) return true; return visited_lookups->has (lookup_index); @@ -3397,7 +3397,7 @@ struct GSUBGPOS hb_set_t alternate_feature_indices; if (version.to_int () >= 0x00010001u) (this+featureVars).closure_features (lookup_indices, &alternate_feature_indices); - if (alternate_feature_indices.in_error()) { + if (unlikely (alternate_feature_indices.in_error())) { feature_indices->successful = false; return; }