aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/elementary/efl_ui_focus_manager_calc.c
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-19 10:18:45 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-20 07:42:41 +0200
commitcbf7d71eebb3be9dfdf7afe881456d0d5ca80f66 (patch)
treeca9337cf0c3a5d8f87105dbbe4774d13a18fbf2e /src/lib/elementary/efl_ui_focus_manager_calc.c
parentefl_ui_focus_manager_calc: safe if this is root in a flag (diff)
downloadefl-cbf7d71eebb3be9dfdf7afe881456d0d5ca80f66.tar.gz
efl_ui_focus_manager_calc: use a mempool instead of calloc / free
if we are heaving a streak of showing / hiding a lot of widgets we free and calloc the same nodes all the time. This now lowers the amount of callocs / frees that we are doing Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9618
Diffstat (limited to '')
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_calc.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c
index e355c30f97..fa26b515e0 100644
--- a/src/lib/elementary/efl_ui_focus_manager_calc.c
+++ b/src/lib/elementary/efl_ui_focus_manager_calc.c
@@ -87,6 +87,19 @@ typedef struct {
Node *root;
} Efl_Ui_Focus_Manager_Calc_Data;
+static Eina_Mempool *_node_mempool;
+
+static Node*
+node_mem_get(void)
+{
+ return eina_mempool_calloc(_node_mempool, sizeof(Node));
+}
+
+static void
+node_mem_free(Node *n)
+{
+ eina_mempool_free(_node_mempool, n);
+}
static Node* _request_subchild(Node *node);
static void dirty_add(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Node *dirty);
@@ -197,7 +210,7 @@ node_new(Efl_Ui_Focus_Object *focusable, Efl_Ui_Focus_Manager *manager)
{
Node *node;
- node = calloc(1, sizeof(Node));
+ node = node_mem_get();
node->focusable = focusable;
node->manager = manager;
@@ -316,7 +329,7 @@ node_item_free(Node *item)
//free the safed order
ELM_SAFE_FREE(T(item).saved_order, eina_list_free);
- free(item);
+ node_mem_free(item);
}
//FOCUS-STACK HELPERS
@@ -1844,6 +1857,20 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_fetch(Eo *obj, Efl_Ui_Focus_Mana
EOLIAN static void
_efl_ui_focus_manager_calc_class_constructor(Efl_Class *c EINA_UNUSED)
{
+ const char *choice, *tmp;
+
+#ifdef EINA_DEFAULT_MEMPOOL
+ choice = "pass_through";
+#else
+ choice = "chained_mempool";
+#endif
+ tmp = getenv("EINA_MEMPOOL");
+ if (tmp && tmp[0])
+ choice = tmp;
+
+ _node_mempool = eina_mempool_add
+ (choice, "Focus-Node mempool", NULL, sizeof(Node), 20);
+
_focus_log_domain = eina_log_domain_register("elementary-focus", EINA_COLOR_CYAN);
}