perf(grid): do not re-sort the whole result on every staged cell edit (#875) - #970
Merged
Merged
Conversation
…Closes #875) With a sort column active, every staging notification re-sorted all rows (O(N log N), an isolate copy from 3000 rows), and the parent handing over a fresh rows list re-sorted a second time through didUpdateWidget. A cell edit does not change the row count, so keep the current visual order and rebuild the displayed row list from the existing permutation in O(N); the edited row no longer jumps while typing. Re-sort still happens on a sort-column change, row insert/delete, or a filter mapping. didUpdateWidget skips the sort when only the rows list changed and the rows come from the staging buffer, and an in-flight isolate sort is invalidated so it cannot revert fresher values.
ZhuchkaTriplesix
deleted the
issue/875-grid-avoid-full-resort-on-edit
branch
September 28, 2026 08:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание изменений
VirtualResultGridбольше не пересортировывает весь результат при каждом уведомлении staging-буфера. Порядок отображения сохраняется, а список строк пересобирается по существующей перестановке за O(N) (_refreshSortedRowValues). Отредактированная строка не «прыгает» во время ввода.rowIndicesMapping).didUpdateWidgetбольше не сортирует повторно, когда изменился только списокrows, а строки берутся из staging-буфера без фильтра. Раньше родитель (ResultsTab) передавал новый список на каждую правку, и сортировка выполнялась второй раз._sortVersion++), чтобы устаревший результат не откатил свежие значения.result_grid_sorting_model_test.dart(5 новых, в том числе с пересборкой родителя): порядок сохраняется, новое значение видно, удаление после правки попадает в верную model-строку, вставка строки по-прежнему пересортировывает. Проверил, что новые тесты падают на старом коде. Весь файл прогнал локально, 10 проходят.Не входит
effectiveRowsна каждое уведомление (O(R)) остались как были.setStateв_commitEdit: Flutter объединяет их в один build, отдельной правки не потребовалось.Связанные Issue
Closes #875