Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_callback.c Log Message: Reduce allocations during callback registration. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_callback.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- ewl_callback.c 4 Nov 2005 04:34:48 -0000 1.9 +++ ewl_callback.c 13 Nov 2005 06:01:51 -0000 1.10 @@ -88,11 +88,11 @@ found = ecore_hash_get(cb_registration, cb); if (!found) { - cb->id = ++callback_id; - ecore_hash_set(cb_registration, cb, cb); - found = cb; - } else - FREE(cb); + found = NEW(Ewl_Callback, 1); + memcpy(found, cb, sizeof(Ewl_Callback)); + found->id = ++callback_id; + ecore_hash_set(cb_registration, found, found); + } found->references++; @@ -247,7 +247,8 @@ ewl_callback_append(Ewl_Widget *w, Ewl_Callback_Type t, Ewl_Callback_Function f, void *user_data) { - Ewl_Callback *cb; + Ewl_Callback cb; + Ewl_Callback *found; int ret; DENTER_FUNCTION(DLEVEL_STABLE); @@ -255,15 +256,13 @@ DCHECK_PARAM_PTR_RET("f", f, 0); DCHECK_TYPE_RET("w", w, "widget", 0); - cb = NEW(Ewl_Callback, 1); - if (!cb) - DRETURN_INT(0, DLEVEL_STABLE); - - cb->func = f; - cb->user_data = user_data; + cb.func = f; + cb.user_data = user_data; + cb.references = 0; + cb.id = 0; - cb = ewl_callback_register(cb); - ret = ewl_callback_insert(w, t, cb, EWL_CALLBACK_LEN(w, t)); + found = ewl_callback_register(&cb); + ret = ewl_callback_insert(w, t, found, EWL_CALLBACK_LEN(w, t)); DRETURN_INT(ret, DLEVEL_STABLE); } @@ -283,7 +282,8 @@ ewl_callback_prepend(Ewl_Widget *w, Ewl_Callback_Type t, Ewl_Callback_Function f, void *user_data) { - Ewl_Callback *cb; + Ewl_Callback cb; + Ewl_Callback *found; int ret; DENTER_FUNCTION(DLEVEL_STABLE); @@ -291,15 +291,13 @@ DCHECK_PARAM_PTR_RET("f", f, 0); DCHECK_TYPE_RET("w", w, "widget", 0); - cb = NEW(Ewl_Callback, 1); - if (!cb) - DRETURN_INT(0, DLEVEL_STABLE); - - cb->func = f; - cb->user_data = user_data; + cb.func = f; + cb.user_data = user_data; + cb.references = 0; + cb.id = 0; - cb = ewl_callback_register(cb); - ret = ewl_callback_insert(w, t, cb, 0); + found = ewl_callback_register(&cb); + ret = ewl_callback_insert(w, t, found, 0); DRETURN_INT(ret, DLEVEL_STABLE); } @@ -322,7 +320,8 @@ Ewl_Callback_Function f, void *user_data, Ewl_Callback_Function after, void *after_data) { - Ewl_Callback *cb; + Ewl_Callback cb; + Ewl_Callback *found; Ewl_Callback *search; int ret, pos = 0; @@ -331,14 +330,12 @@ DCHECK_PARAM_PTR_RET("f", f, 0); DCHECK_TYPE_RET("w", w, "widget", 0); - cb = NEW(Ewl_Callback, 1); - if (!cb) - DRETURN_INT(0, DLEVEL_STABLE); - - cb->func = f; - cb->user_data = user_data; + cb.func = f; + cb.user_data = user_data; + cb.references = 0; + cb.id = 0; - cb = ewl_callback_register(cb); + found = ewl_callback_register(&cb); /* * Step 1 position past the callback we want to insert after. @@ -352,7 +349,7 @@ break; } } - ret = ewl_callback_insert(w, t, cb, pos); + ret = ewl_callback_insert(w, t, found, pos); DRETURN_INT(ret, DLEVEL_STABLE); } ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs