summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-08-05 11:53:19 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-08-05 11:53:19 +0200
commit9852b2b71410fa16051397f247b0ecaeb5245695 (patch)
treef6a6906bfe8695b0e9ddb5b2eeb2cd49607ea999
parent5dbc62a98bd72a3a1f88f4acf5586b00c9151dc3 (diff)
Revert "eo: make callback_add faster"devs/bu5hm4n/perf
This reverts commit d34a0321cba607392ef07739322e963419bd5af5.
-rw-r--r--src/lib/eo/eo_base_class.c55
1 files changed, 19 insertions, 36 deletions
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index c9b8859a4e..e076402819 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -89,7 +89,6 @@ struct _Efl_Object_Data
89 Eina_Bool need_cleaning : 1; 89 Eina_Bool need_cleaning : 1;
90 90
91 Eina_Bool allow_parent_unref : 1; // Allows unref to zero even with a parent 91 Eina_Bool allow_parent_unref : 1; // Allows unref to zero even with a parent
92 Eina_Bool single_priority : 1;
93}; 92};
94 93
95typedef enum 94typedef enum
@@ -1477,9 +1476,19 @@ _eo_callback_search_sorted_near(const Efl_Object_Data *pd, const Eo_Callback_Des
1477 return middle; 1476 return middle;
1478} 1477}
1479 1478
1480static inline void 1479static void
1481_eo_callbacks_array_bump(Efl_Object_Data *pd) 1480_eo_callbacks_sorted_insert(Efl_Object_Data *pd, Eo_Callback_Description *cb)
1482{ 1481{
1482 Eo_Callback_Description **itr;
1483 unsigned int length, j;
1484 Efl_Event_Callback_Frame *frame;
1485
1486 // Do a dichotomic searh
1487 j = _eo_callback_search_sorted_near(pd, cb);
1488 // Adjust for both case of length == 0 and when priority is equal.
1489 while ((j < pd->callbacks_count) &&
1490 (pd->callbacks[j]->priority >= cb->priority)) j++;
1491
1483 // Increase the callbacks storage by 16 entries at a time 1492 // Increase the callbacks storage by 16 entries at a time
1484 if (_eo_nostep_alloc || (pd->callbacks_count & 0xF) == 0x0) 1493 if (_eo_nostep_alloc || (pd->callbacks_count & 0xF) == 0x0)
1485 { 1494 {
@@ -1493,38 +1502,14 @@ _eo_callbacks_array_bump(Efl_Object_Data *pd)
1493 if (EINA_UNLIKELY(!tmp)) return; 1502 if (EINA_UNLIKELY(!tmp)) return;
1494 pd->callbacks = tmp; 1503 pd->callbacks = tmp;
1495 } 1504 }
1496}
1497 1505
1498static void 1506 // FIXME: Potential improvement, merge single callback description of the same priority
1499_eo_callbacks_sorted_insert(Efl_Object_Data *pd, Eo_Callback_Description *cb) 1507 // into an array when possible
1500{ 1508 itr = pd->callbacks + j;
1501 Eo_Callback_Description **itr; 1509 length = pd->callbacks_count - j;
1502 unsigned int length, j; 1510 if (length > 0) memmove(itr + 1, itr,
1503 Efl_Event_Callback_Frame *frame; 1511 length * sizeof(Eo_Callback_Description *));
1504 1512 *itr = cb;
1505 if (pd->single_priority && cb->priority == 0)
1506 {
1507 _eo_callbacks_array_bump(pd);
1508 pd->callbacks[pd->callbacks_count] = cb;
1509 }
1510 else
1511 {
1512 pd->single_priority = EINA_FALSE;
1513 // Do a dichotomic searh
1514 j = _eo_callback_search_sorted_near(pd, cb);
1515 // Adjust for both case of length == 0 and when priority is equal.
1516 while ((j < pd->callbacks_count) &&
1517 (pd->callbacks[j]->priority >= cb->priority)) j++;
1518 _eo_callbacks_array_bump(pd);
1519 // FIXME: Potential improvement, merge single callback description of the same priority
1520 // into an array when possible
1521 itr = pd->callbacks + j;
1522 length = pd->callbacks_count - j;
1523 if (length > 0) memmove(itr + 1, itr,
1524 length * sizeof(Eo_Callback_Description *));
1525 *itr = cb;
1526
1527 }
1528 1513
1529 pd->callbacks_count++; 1514 pd->callbacks_count++;
1530 1515
@@ -2677,8 +2662,6 @@ _efl_object_constructor(Eo *obj, Efl_Object_Data *pd EINA_UNUSED)
2677{ 2662{
2678 DBG("%p - %s.", obj, efl_class_name_get(obj)); 2663 DBG("%p - %s.", obj, efl_class_name_get(obj));
2679 2664
2680 pd->single_priority = EINA_TRUE;
2681
2682 _eo_condtor_done(obj); 2665 _eo_condtor_done(obj);
2683 2666
2684 return obj; 2667 return obj;