This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 93b2ad6aa09dab34958e54451d86b8718cb00719
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Nov 10 17:59:07 2026 -0600
elementary: collection_view: take row sizes from the Exact_Model
Every row added to a live view makes the position manager rebuild its
size cache, which asks the view for the size of every row. For a model
that is not homogeneous each answer went through the cache of rows, and
through the property chain of the models wrapped around the Exact_Model
for those that were in it, which is far more than the answer is worth.
Adding rows one at a time was quadratic with a large constant: 2000 of
them took 5.4 s with a loop that idles between them, 16 s without, where
the same rows over a homogeneous model take 1.8 s.
The Exact_Model remembers the sizes it was told, so the view finds it
once under its own wrappers and reads them from there. The rows that
were never measured are still fetched and measured as before. 2000
additions take 1.8 s, as with the homogeneous model.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_collection_view.c | 34 +++++++++---------
src/lib/elementary/efl_ui_exact_model.c | 28 ++++++++-------
src/lib/elementary/elm_priv.h | 3 +-
src/tests/elementary/efl_ui_test_collection_view.c | 40 ++++++++++++++++++++++
4 files changed, 76 insertions(+), 29 deletions(-)
diff --git a/src/lib/elementary/efl_ui_collection_view.c b/src/lib/elementary/efl_ui_collection_view.c
index 69ec22d7a6..00089523c9 100644
--- a/src/lib/elementary/efl_ui_collection_view.c
+++ b/src/lib/elementary/efl_ui_collection_view.c
@@ -885,7 +885,7 @@ _build_from_focus(Efl_Ui_Collection_View_Data *pd, unsigned int search_index,
static Eina_List *
_cache_size_fetch(Eina_List *requests, Efl_Ui_Collection_Request **request,
- Efl_Ui_Collection_View_Data *pd,
+ Efl_Ui_Collection_View_Data *pd, Efl_Model *exact,
unsigned int search_index,
Efl_Ui_Position_Manager_Size_Batch_Entity *target,
Eina_Size2D item_base)
@@ -894,6 +894,18 @@ _cache_size_fetch(Eina_List *requests, Efl_Ui_Collection_Request **request,
Efl_Model *model = NULL;
Eina_Size2D item_size = item_base;
+ /* A row measured is of the size it was told to be, whether the view has
+ it at hand or let go of it (the position manager has that size cached,
+ and finds the sizes changed under it if told another). An Exact_Model
+ remembers them, and is quicker to ask than the row is to be found. */
+ if (exact && _efl_ui_exact_model_row_size_get(exact, search_index, &item_size))
+ {
+ target->size = item_size;
+ target->element_depth = 0;
+ target->depth_leader = EINA_FALSE;
+ return requests;
+ }
+
if (!pd->cache) goto not_found;
lookup = (void*) eina_rbtree_inline_lookup(pd->cache, &search_index,
@@ -939,17 +951,6 @@ _cache_size_fetch(Eina_List *requests, Efl_Ui_Collection_Request **request,
return requests;
not_found:
- /* A row let go of is still of the size it was told to be, and the
- position manager has that size cached: saying anything else makes it
- find the sizes changed under it. An Exact_Model remembers them. */
- if (_efl_ui_exact_model_row_size_get(pd->model, search_index, &item_size))
- {
- target->size = item_size;
- target->element_depth = 0;
- target->depth_leader = EINA_FALSE;
- return requests;
- }
-
requests = _request_add(requests, request, search_index, EINA_FALSE);
target->size = item_size;
@@ -1153,7 +1154,7 @@ _batch_size_cb(void *data, Efl_Ui_Position_Manager_Size_Call_Config conf, Eina_R
Efl_Ui_Position_Manager_Size_Batch_Entity *sizes;
Efl_Ui_Collection_Request *request = NULL;
Efl_Ui_Position_Manager_Size_Batch_Result result = {0};
- Efl_Model *parent;
+ Efl_Model *parent, *exact;
Eina_List *requests = NULL;
Eina_Size2D item_base = {0};
unsigned int limit;
@@ -1161,6 +1162,7 @@ _batch_size_cb(void *data, Efl_Ui_Position_Manager_Size_Call_Config conf, Eina_R
// get the approximate value from the tree node
parent = pd->model;
+ exact = _efl_ui_exact_model_find(parent);
sizes = memory.mem;
//count = efl_model_children_count_get(parent);
@@ -1194,7 +1196,7 @@ _batch_size_cb(void *data, Efl_Ui_Position_Manager_Size_Call_Config conf, Eina_R
while ((unsigned int)(conf.range.start_id + idx) < pd->viewport[0]->offset && idx < limit)
{
unsigned int search_index = conf.range.start_id + idx;
- requests = _cache_size_fetch(requests, &request, pd,
+ requests = _cache_size_fetch(requests, &request, pd, exact,
search_index, &sizes[idx], item_base);
idx++;
}
@@ -1266,7 +1268,7 @@ _batch_size_cb(void *data, Efl_Ui_Position_Manager_Size_Call_Config conf, Eina_R
while (idx < limit)
{
unsigned int search_index = conf.range.start_id + idx;
- requests = _cache_size_fetch(requests, &request, pd,
+ requests = _cache_size_fetch(requests, &request, pd, exact,
search_index, &sizes[idx], item_base);
idx++;
}
@@ -1307,7 +1309,7 @@ _batch_size_cb(void *data, Efl_Ui_Position_Manager_Size_Call_Config conf, Eina_R
while (idx < limit)
{
unsigned int search_index = conf.range.start_id + idx;
- requests = _cache_size_fetch(requests, &request, pd,
+ requests = _cache_size_fetch(requests, &request, pd, exact,
search_index, &sizes[idx], item_base);
idx++;
}
diff --git a/src/lib/elementary/efl_ui_exact_model.c b/src/lib/elementary/efl_ui_exact_model.c
index e2e64106f0..7db041104e 100644
--- a/src/lib/elementary/efl_ui_exact_model.c
+++ b/src/lib/elementary/efl_ui_exact_model.c
@@ -416,25 +416,29 @@ _efl_ui_exact_model_efl_model_property_get(const Eo *obj, Efl_Ui_Exact_Model_Dat
return efl_model_property_get(efl_super(obj, EFL_UI_EXACT_MODEL_CLASS), property);
}
-/* The size of a row as it was told to the model, without the row itself:
- the view asks for rows it has let go of and cannot wait for them. */
-Eina_Bool
-_efl_ui_exact_model_row_size_get(Efl_Model *model, unsigned int index, Eina_Size2D *size)
+/* The Exact_Model under the models the view wraps its own around, or NULL. */
+Efl_Model *
+_efl_ui_exact_model_find(Efl_Model *model)
{
- Efl_Ui_Exact_Model_Data *root;
- unsigned int w, h;
- unsigned char found;
-
- /* The view wraps the model it is given in models of its own. */
while (model && !efl_isa(model, EFL_UI_EXACT_MODEL_CLASS))
{
if (!efl_isa(model, EFL_COMPOSITE_MODEL_CLASS) ||
!efl_isa(model, EFL_UI_VIEW_INTERFACE))
- return EINA_FALSE;
+ return NULL;
model = efl_ui_view_model_get(model);
}
- if (!model) return EINA_FALSE;
- root = efl_data_scope_get(model, EFL_UI_EXACT_MODEL_CLASS);
+ return model;
+}
+
+/* The size of a row as it was told to the model, without the row itself:
+ the view asks for rows it has let go of and cannot wait for them. */
+Eina_Bool
+_efl_ui_exact_model_row_size_get(Efl_Model *exact, unsigned int index, Eina_Size2D *size)
+{
+ Efl_Ui_Exact_Model_Data *root = efl_data_scope_get(exact, EFL_UI_EXACT_MODEL_CLASS);
+ unsigned int w, h;
+ unsigned char found;
+
if (!root || root->parent) return EINA_FALSE;
found = _efl_ui_exact_model_slot_find(root, index, EINA_TRUE, EINA_TRUE);
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index dbe3381774..4347673327 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -653,7 +653,8 @@ struct _Elm_Module
int references;
};
-Eina_Bool _efl_ui_exact_model_row_size_get(Efl_Model *model,
+Efl_Model *_efl_ui_exact_model_find(Efl_Model *model);
+Eina_Bool _efl_ui_exact_model_row_size_get(Efl_Model *exact,
unsigned int index,
Eina_Size2D *size);
Eina_Bool _elm_web_init(const char *engine);
diff --git a/src/tests/elementary/efl_ui_test_collection_view.c b/src/tests/elementary/efl_ui_test_collection_view.c
index bd58b1b5da..7464e4a286 100644
--- a/src/tests/elementary/efl_ui_test_collection_view.c
+++ b/src/tests/elementary/efl_ui_test_collection_view.c
@@ -1038,6 +1038,45 @@ EFL_START_TEST(test_efl_ui_collection_view_exact_model_jump)
}
EFL_END_TEST
+/* Rows are added one at a time to a view that is showing the model, as a
+ listing arriving does, and the loop is let to idle in between. */
+static void
+_single_adds(Efl_Model *model, int rows)
+{
+ int i;
+
+ for (i = 0; i < rows; i++)
+ {
+ efl_model_child_add(model);
+ wait_timer(0.0);
+ }
+}
+
+/* A view over an Exact_Model is asked the size of every row each time one
+ comes in. How long 2000 of them take depends on the machine, and is not
+ asserted. */
+EFL_START_TEST(test_efl_ui_collection_view_many_single_adds)
+{
+ Efl_Ui_Win *win;
+ Efl_Model *model, *sizes;
+ Efl_Ui_List_View *lv;
+ int i;
+ const int rows = 2000;
+
+ win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+ efl_gfx_entity_size_set(win, EINA_SIZE2D(200, 300));
+ lv = _exact_list(win, &sizes);
+ model = efl_ui_view_model_get(sizes);
+ get_me_to_those_events(lv);
+ for (i = 0; i < 50; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ _single_adds(model, rows);
+ ck_assert_int_eq(efl_model_children_count_get(model), NUM_ITEMS + rows);
+}
+EFL_END_TEST
+
void efl_ui_test_collection_view(TCase *tc)
{
tcase_add_test(tc, test_efl_ui_collection_view_basic);
@@ -1058,4 +1097,5 @@ void efl_ui_test_collection_view(TCase *tc)
tcase_add_test(tc, test_efl_ui_collection_view_sizes_agree);
tcase_add_test(tc, test_efl_ui_collection_view_remove_last_row);
tcase_add_test(tc, test_efl_ui_collection_view_exact_model_jump);
+ tcase_add_test(tc, test_efl_ui_collection_view_many_single_adds);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.