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 dfe7ef27b779f68d85f5f28820bf18a17c1cbc9b
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Nov 10 20:27:17 2026 -0600

    elementary: exact_model: stop the widest-row scan at the old width
    
    When every row is as wide, each removal of one of them expanded every
    block to look for the widest. The width of the row that left is the most
    there was, so the first row found that is as wide ends the search, and
    when the rows that are left are alike nothing but the first block is
    expanded.
    
    This is not a measurable speedup of a removal at the sizes the tests
    use: 2100 rows removed from the front, every third one measured, take
    about 740 ms with or without it (plain build, same machine, three runs
    each), as shifting the sizes of the rows at each removal costs far more
    than the scan. The test checks the total width after each of those
    removals.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_exact_model.c | 14 +++++++++-----
 src/tests/elementary/efl_ui_model.c     | 22 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/src/lib/elementary/efl_ui_exact_model.c b/src/lib/elementary/efl_ui_exact_model.c
index c4b0a7792a..4a206b67c8 100644
--- a/src/lib/elementary/efl_ui_exact_model.c
+++ b/src/lib/elementary/efl_ui_exact_model.c
@@ -518,9 +518,11 @@ _efl_ui_exact_model_list_remove(Eina_List *compressed, unsigned int index,
 }
 
 // The widest row of what the list holds (the total width is that of one row,
-// as it is a vertical list that is kept).
+// as it is a vertical list that is kept). It is no wider than "known", so as
+// soon as a row is that wide there is no need to look further: when the
+// rows that are left are alike, nothing but the first block is expanded.
 static unsigned int
-_efl_ui_exact_model_width_max(Eina_List *compressed)
+_efl_ui_exact_model_width_max(Eina_List *compressed, unsigned int known)
 {
    unsigned int buffer[EFL_UI_EXACT_MODEL_CONTENT];
    unsigned int max = 0, i;
@@ -532,8 +534,9 @@ _efl_ui_exact_model_width_max(Eina_List *compressed)
         _efl_ui_exact_model_block_load(l, buffer);
         for (i = 0; i < EFL_UI_EXACT_MODEL_CONTENT; i++)
           {
-             if (buffer[i] & EFL_UI_EXACT_MODEL_MEASURED)
-               max = MAX(max, buffer[i] & ~EFL_UI_EXACT_MODEL_MEASURED);
+             if (!(buffer[i] & EFL_UI_EXACT_MODEL_MEASURED)) continue;
+             max = MAX(max, buffer[i] & ~EFL_UI_EXACT_MODEL_MEASURED);
+             if (max >= known) return max;
           }
      }
    return max;
@@ -612,7 +615,8 @@ _efl_ui_exact_model_shift(Efl_Ui_Exact_Model_Data *root, unsigned int index, Ein
         // The total width is the widest row: only when it was that one is it to be looked for again
         if ((w & EFL_UI_EXACT_MODEL_MEASURED) &&
             (w & ~EFL_UI_EXACT_MODEL_MEASURED) >= root->total_size.width)
-          root->total_size.width = _efl_ui_exact_model_width_max(root->compressed.width);
+          root->total_size.width = _efl_ui_exact_model_width_max(root->compressed.width,
+                                          root->total_size.width);
      }
 }
 
diff --git a/src/tests/elementary/efl_ui_model.c b/src/tests/elementary/efl_ui_model.c
index 2b3bcc3e25..bc88a10549 100644
--- a/src/tests/elementary/efl_ui_model.c
+++ b/src/tests/elementary/efl_ui_model.c
@@ -1187,6 +1187,27 @@ EFL_START_TEST(efl_ui_average_model_forgotten)
 }
 EFL_END_TEST
 
+// Rows that are all as wide: the total width is theirs as long as one is left.
+EFL_START_TEST(efl_ui_exact_model_remove_widest_alike)
+{
+   Shift_Rows *sr = _shift_new(2100);
+   unsigned int i;
+
+   for (i = 0; i < 2100; i += 3)
+     efl_future_then(sr->cur[i], efl_model_property_set(sr->cur[i], "self.width",
+                                                         eina_value_uint_new(60)));
+   ck_assert_uint_eq(_property_uint_expected(sr->model, "total.width"), 60);
+   // (every third row is measured: the last of them is the row 2097)
+   for (i = 0; i < 2100; i++)
+     {
+        _shift_remove(sr, 0);
+        ck_assert_uint_eq(_property_uint_expected(sr->model, "total.width"),
+                          i < 2097 ? 60 : 0);
+     }
+   _shift_free(sr);
+}
+EFL_END_TEST
+
 // Blocks that are all measured: what falls out of the last block as the rows
 // move is a size too, and has a block of its own.
 EFL_START_TEST(efl_ui_exact_model_shift_overflow)
@@ -1344,6 +1365,7 @@ efl_ui_model(TCase *tc)
    tcase_add_test(tc, efl_ui_exact_model_shift_store_fails);
    tcase_add_test(tc, efl_ui_average_model_forgotten);
    tcase_add_test(tc, efl_ui_exact_model_remove_widest);
+   tcase_add_test(tc, efl_ui_exact_model_remove_widest_alike);
    tcase_add_test(tc, efl_ui_exact_model_destroyed);
    tcase_add_test(tc, efl_ui_average_model_forgotten_in_set);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to