[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)) \
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

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)) \
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