efl_ui_widget: Save some pointer indirection

We're getting the same widget data twice, as well as testing if the
object is a widget twice.  Let's do these things once.

Signed-off-by: Derek Foreman <derek.foreman.samsung@gmail.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D7698
This commit is contained in:
Derek Foreman 2019-01-18 13:39:46 -06:00
parent 014705c740
commit d14c700e9d
1 changed files with 7 additions and 7 deletions

View File

@ -1469,24 +1469,26 @@ EOLIAN static Eina_Bool
_efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
{
Eina_Bool mirrored, pmirrored = efl_ui_mirrored_get(obj);
Elm_Widget_Smart_Data *sdc = NULL;
EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
if (_elm_widget_is(sobj))
sdc = efl_data_scope_get(sobj, MY_CLASS);
if (sobj == sd->parent_obj)
{
/* in this case, sobj must be an elm widget, or something
* very wrong is happening */
if (!_elm_widget_is(sobj)) return EINA_FALSE;
if (!sdc) return EINA_FALSE;
if (!elm_widget_sub_object_del(sobj, obj)) return EINA_FALSE;
WRN("You passed a parent object of obj = %p as the sub object = %p!",
obj, sobj);
}
if (_elm_widget_is(sobj))
if (sdc)
{
ELM_WIDGET_DATA_GET(sobj, sdc);
if (sdc->parent_obj == obj) goto end;
if (sdc->parent_obj)
{
@ -1543,10 +1545,8 @@ _efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
evas_object_data_set(sobj, "elm-parent", obj);
_callbacks_add(sobj, obj);
if (_elm_widget_is(sobj))
if (sdc)
{
ELM_WIDGET_DATA_GET(sobj, sdc);
/* NOTE: In the following two lines, 'sobj' is correct. Do not change it.
* Due to elementary's scale policy, scale and pscale can be different in
* some cases. This happens when sobj's previous parent and new parent have