[font/draw] Remove unneeded branch

The preamble sets user_data/destroy to nullptr if func is nullptr.
This commit is contained in:
Behdad Esfahbod 2022-11-19 15:08:50 -07:00
parent 976bb26cc1
commit 56d6b6992b
2 changed files with 14 additions and 23 deletions

View File

@ -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)) \ if (!_hb_draw_funcs_set_middle (dfuncs, user_data, destroy)) \
return; \ return; \
\ \
if (func) { \ if (func) \
dfuncs->func.name = func; \ dfuncs->func.name = func; \
else \
dfuncs->func.name = hb_draw_##name##_nil; \
\
if (dfuncs->user_data) \ if (dfuncs->user_data) \
dfuncs->user_data->name = user_data; \ dfuncs->user_data->name = user_data; \
if (dfuncs->destroy) \ if (dfuncs->destroy) \
dfuncs->destroy->name = destroy; \ dfuncs->destroy->name = destroy; \
} 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; \
} }
HB_DRAW_FUNCS_IMPLEMENT_CALLBACKS HB_DRAW_FUNCS_IMPLEMENT_CALLBACKS

View File

@ -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)) \ if (!_hb_font_funcs_set_middle (ffuncs, user_data, destroy)) \
return; \ return; \
\ \
if (func) { \ if (func) \
ffuncs->get.f.name = func; \ ffuncs->get.f.name = func; \
else \
ffuncs->get.f.name = hb_font_get_##name##_default; \
\
if (ffuncs->user_data) \ if (ffuncs->user_data) \
ffuncs->user_data->name = user_data; \ ffuncs->user_data->name = user_data; \
if (ffuncs->destroy) \ if (ffuncs->destroy) \
ffuncs->destroy->name = destroy; \ ffuncs->destroy->name = destroy; \
} 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; \
} \
} }
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS HB_FONT_FUNCS_IMPLEMENT_CALLBACKS