From d85048c93f894e5abd7ebbf813389b0329ee6956 Mon Sep 17 00:00:00 2001 From: ningerso Date: Fri, 4 Aug 2006 10:00:50 +0000 Subject: [PATCH] Did some cache miss profiling with a large number of transient text objects and found that reordering the evas list containing the font path list was actually hurting cache performance. Frequent cache misses occurred in evas_mempool_free in it's main loop. So removing the list node and re adding it actually decreased cache performance in some cases. This would also cause memory allocation bouncing if mempools were not used. Added evas_list_promote_list to move a list node to the beginning of a list. Changed reordering lists to use evas_list_promote_list. SVN revision: 24387 --- legacy/evas/src/lib/Evas.h | 1 + legacy/evas/src/lib/canvas/evas_font_dir.c | 3 +- legacy/evas/src/lib/data/evas_list.c | 53 +++++++++++++++++++ .../src/lib/engines/common/evas_image_load.c | 3 +- legacy/evas/src/lib/file/evas_module.c | 3 +- 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/legacy/evas/src/lib/Evas.h b/legacy/evas/src/lib/Evas.h index f7de1d065e..75bb3e5e94 100644 --- a/legacy/evas/src/lib/Evas.h +++ b/legacy/evas/src/lib/Evas.h @@ -319,6 +319,7 @@ extern "C" { EAPI Evas_List *evas_list_prepend_relative_list (Evas_List *list, const void *data, Evas_List *relative); EAPI Evas_List *evas_list_remove (Evas_List *list, const void *data); EAPI Evas_List *evas_list_remove_list (Evas_List *list, Evas_List *remove_list); + EAPI Evas_List *evas_list_promote_list (Evas_List *list, Evas_List *move_list); EAPI void *evas_list_find (Evas_List *list, const void *data); EAPI Evas_List *evas_list_find_list (Evas_List *list, const void *data); EAPI Evas_List *evas_list_free (Evas_List *list); diff --git a/legacy/evas/src/lib/canvas/evas_font_dir.c b/legacy/evas/src/lib/canvas/evas_font_dir.c index 8fd2eb500b..fbf1241b48 100644 --- a/legacy/evas/src/lib/canvas/evas_font_dir.c +++ b/legacy/evas/src/lib/canvas/evas_font_dir.c @@ -151,8 +151,7 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size) { if (size == fd->size) { - fonts_cache = evas_list_remove_list(fonts_cache, l); - fonts_cache = evas_list_prepend(fonts_cache, fd); + fonts_cache = evas_list_promote_list(fonts_cache, l); fd->ref++; return fd->font; } diff --git a/legacy/evas/src/lib/data/evas_list.c b/legacy/evas/src/lib/data/evas_list.c index 22711e7055..09393f1001 100644 --- a/legacy/evas/src/lib/data/evas_list.c +++ b/legacy/evas/src/lib/data/evas_list.c @@ -403,6 +403,59 @@ evas_list_remove_list(Evas_List *list, Evas_List *remove_list) return return_l; } +/** + * Moves the specified data to the head of the list + * + * Move a specified member to the head of the list + * @param list The list handle to move @p inside + * @param move_list The list node which is to be moved + * @return A new list handle to replace the old one + * + * Calling this function takes the list node @p move_list and moves it + * to the front of the @p list. + * + * Example: + * @code + * extern Evas_List *list; + * Evas_List *l; + * extern void *my_data; + * + * for (l = list; l; l= l->next) + * { + * if (l->data == my_data) + * { + * list = evas_list_promote_list(list, l); + * break; + * } + * } + * @endcode + * @ingroup Evas_List_Promote_Group + */ +EAPI Evas_List * +evas_list_promote_list(Evas_List *list, Evas_List *move_list) +{ + Evas_List *return_l; + + if (!list) return NULL; + if (!move_list) return list; + if (move_list == list) return list; + if (move_list->next) move_list->next->prev = move_list->prev; + if (move_list->prev) + { + move_list->prev->next = move_list->next; + return_l = list; + } + else + return_l = move_list->next; + if (move_list == ((Evas_List_Accounting *)(list->accounting))->last) + ((Evas_List_Accounting *)(list->accounting))->last = move_list->prev; + move_list->prev = NULL; + move_list->next = return_l; + return move_list; +} + + + /** * @defgroup Evas_List_Find_Group Linked List Find Functions * diff --git a/legacy/evas/src/lib/engines/common/evas_image_load.c b/legacy/evas/src/lib/engines/common/evas_image_load.c index 98f6a734ab..98b9b9be57 100644 --- a/legacy/evas/src/lib/engines/common/evas_image_load.c +++ b/legacy/evas/src/lib/engines/common/evas_image_load.c @@ -66,8 +66,7 @@ evas_common_load_image_from_file(const char *file, const char *key) { if (evas_modules != l) { - evas_modules = evas_list_remove_list(evas_modules, l); - evas_modules = evas_list_prepend(evas_modules, em); + evas_modules = evas_list_promote_list(evas_modules, l); } goto ok; } diff --git a/legacy/evas/src/lib/file/evas_module.c b/legacy/evas/src/lib/file/evas_module.c index b654c05442..aeb28ec4c2 100644 --- a/legacy/evas/src/lib/file/evas_module.c +++ b/legacy/evas/src/lib/file/evas_module.c @@ -207,8 +207,7 @@ evas_module_find_type(Evas_Module_Type type, const char *name) { if (evas_modules != l) { - evas_modules = evas_list_remove_list(evas_modules, l); - evas_modules = evas_list_prepend(evas_modules, em); + evas_modules = evas_list_promote_list(evas_modules, l); } return em; }