summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-06-15 00:33:08 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-06-15 08:43:51 +0100
commit7c081c691b983e93693557cc39b06883f1ab142a (patch)
treef544e7b6d9a415aac0fb2832bf476ea52240f695
parentc2d1aaaed6b5cb7a30930d950f0490750d33eb1e (diff)
edje messages - use trash to keep message structs around for a short time
more optimizations for edje messages to avoid excess alloc and frees if we have some trash around... since messages already have list nodes, re-use the main list node for storing trash and not eina trash as this avoids extra allocs for trash nodes.
-rw-r--r--src/lib/edje/edje_message_queue.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/src/lib/edje/edje_message_queue.c b/src/lib/edje/edje_message_queue.c
index db5542b06e..2e7e7ad9ba 100644
--- a/src/lib/edje/edje_message_queue.c
+++ b/src/lib/edje/edje_message_queue.c
@@ -11,10 +11,45 @@ static Eina_Inlist *tmp_msgq = NULL;
11static int tmp_msgq_processing = 0; 11static int tmp_msgq_processing = 0;
12static int tmp_msgq_restart = 0; 12static int tmp_msgq_restart = 0;
13 13
14static Eina_Inlist *_edje_msg_trash = NULL;
15
14/*============================================================================* 16/*============================================================================*
15* API * 17* API *
16*============================================================================*/ 18*============================================================================*/
17 19
20#define INLIST_CONTAINER(container_type, list, list_entry) \
21 (container_type *)((unsigned char *)list - offsetof(container_type, list_entry))
22
23static Edje_Message *
24_edje_msg_trash_pop(void)
25{
26 Edje_Message *em;
27
28 if (!_edje_msg_trash) return NULL;
29 em = INLIST_CONTAINER(Edje_Message, _edje_msg_trash, inlist_main);
30 _edje_msg_trash = eina_inlist_remove(_edje_msg_trash, &(em->inlist_main));
31 memset(em, 0, sizeof(Edje_Message));
32 return em;
33}
34
35static void
36_edje_msg_trash_push(Edje_Message *em)
37{
38 _edje_msg_trash = eina_inlist_prepend(_edje_msg_trash, &(em->inlist_main));
39}
40
41static void
42_edje_msg_trash_clear(void)
43{
44 Edje_Message *em;
45
46 while (_edje_msg_trash)
47 {
48 em = _edje_msg_trash_pop();
49 free(em);
50 }
51}
52
18static void 53static void
19_edje_object_message_propagate_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg, Eina_Bool prop) 54_edje_object_message_propagate_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg, Eina_Bool prop)
20{ 55{
@@ -141,9 +176,6 @@ bad_type:
141 return; 176 return;
142} 177}
143 178
144#define INLIST_CONTAINER(container_type, list, list_entry) \
145 (container_type *)((unsigned char *)list - offsetof(container_type, list_entry))
146
147static void 179static void
148_edje_object_message_signal_process_do(Eo *obj EINA_UNUSED, Edje *ed) 180_edje_object_message_signal_process_do(Eo *obj EINA_UNUSED, Edje *ed)
149{ 181{
@@ -259,6 +291,7 @@ _edje_job(void *data EINA_UNUSED)
259 _job = NULL; 291 _job = NULL;
260 _injob++; 292 _injob++;
261 _edje_message_queue_process(); 293 _edje_message_queue_process();
294 _edje_msg_trash_clear();
262 _injob--; 295 _injob--;
263} 296}
264 297
@@ -282,6 +315,7 @@ void
282_edje_message_shutdown(void) 315_edje_message_shutdown(void)
283{ 316{
284 _edje_message_queue_clear(); 317 _edje_message_queue_clear();
318 _edje_msg_trash_clear();
285 if (_job_loss_timer) 319 if (_job_loss_timer)
286 { 320 {
287 ecore_timer_del(_job_loss_timer); 321 ecore_timer_del(_job_loss_timer);
@@ -315,7 +349,8 @@ _edje_message_new(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id)
315{ 349{
316 Edje_Message *em; 350 Edje_Message *em;
317 351
318 em = calloc(1, sizeof(Edje_Message)); 352 em = _edje_msg_trash_pop();
353 if (!em) em = calloc(1, sizeof(Edje_Message));
319 if (!em) return NULL; 354 if (!em) return NULL;
320 em->edje = ed; 355 em->edje = ed;
321 em->queue = queue; 356 em->queue = queue;
@@ -448,7 +483,7 @@ _edje_message_free(Edje_Message *em)
448 break; 483 break;
449 } 484 }
450 } 485 }
451 free(em); 486 _edje_msg_trash_push(em);
452} 487}
453 488
454static void 489static void