From 56d6b6992b630ea81b681b2876dbcee97164b617 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod <behdad@behdad.org> Date: Sat, 19 Nov 2022 15:08:50 -0700 Subject: [PATCH] [font/draw] Remove unneeded branch The preamble sets user_data/destroy to nullptr if func is nullptr. --- src/hb-draw.cc | 19 +++++++------------ src/hb-font.cc | 18 +++++++----------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/hb-draw.cc b/src/hb-draw.cc index 14c73eafa..72c203f24 100644 --- a/src/hb-draw.cc +++ b/src/hb-draw.cc @@ -147,20 +147,15 @@ hb_draw_funcs_set_##name##_func (hb_draw_funcs_t *dfuncs, \ if (!_hb_draw_funcs_set_middle (dfuncs, user_data, destroy)) \ return; \ \ - if (func) { \ + if (func) \ dfuncs->func.name = func; \ - if (dfuncs->user_data) \ - dfuncs->user_data->name = user_data; \ - if (dfuncs->destroy) \ - dfuncs->destroy->name = destroy; \ - } else { \ + else \ dfuncs->func.name = hb_draw_##name##_nil; \ - if (dfuncs->user_data) \ - dfuncs->user_data->name = nullptr; \ - if (dfuncs->destroy) \ - dfuncs->destroy->name = nullptr; \ - } \ - return; \ + \ + if (dfuncs->user_data) \ + dfuncs->user_data->name = user_data; \ + if (dfuncs->destroy) \ + dfuncs->destroy->name = destroy; \ } HB_DRAW_FUNCS_IMPLEMENT_CALLBACKS diff --git a/src/hb-font.cc b/src/hb-font.cc index 04dd30e29..0fb75b785 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -889,19 +889,15 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \ if (!_hb_font_funcs_set_middle (ffuncs, user_data, destroy)) \ return; \ \ - if (func) { \ + if (func) \ ffuncs->get.f.name = func; \ - if (ffuncs->user_data) \ - ffuncs->user_data->name = user_data; \ - if (ffuncs->destroy) \ - ffuncs->destroy->name = destroy; \ - } else { \ + else \ ffuncs->get.f.name = hb_font_get_##name##_default; \ - if (ffuncs->user_data) \ - ffuncs->user_data->name = nullptr; \ - if (ffuncs->destroy) \ - ffuncs->destroy->name = nullptr; \ - } \ + \ + if (ffuncs->user_data) \ + ffuncs->user_data->name = user_data; \ + if (ffuncs->destroy) \ + ffuncs->destroy->name = destroy; \ } HB_FONT_FUNCS_IMPLEMENT_CALLBACKS