Repository navigation
perf(grid): Index the definition collections (backport #24233) - #25748
Merged
Merged
Conversation
ValidateDefinitions iterated definitions.GetItems(), which hands back the backing DependencyObjectCollection as IEnumerable<DefinitionBase>. Its GetEnumerator returns IEnumerator<T>, boxing the List<T>.Enumerator struct, and the method runs twice per Grid measure -- once for rows, once for columns. Loop by index instead. DefinitionCollectionBase already exposed Count and GetItem(int), and GetItem is _inner[index], the same sequence the enumerator walks, so no new API was needed. GetItems() had exactly one caller and is removed rather than left dead. Measured (specs/059-performance-improvements): a grid layout pass drops 34.5% of its allocations, and the 27,280 B saved is exactly 80 B per grid -- two boxed List<T>.Enumerators, matching the 40 B constant measured independently in the visual-tree accessors. Time is unchanged. 937 runtime tests: identical pass/fail sets, 0 new failures. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015DSdL5YzLhjx8CeGXZf1Au (cherry picked from commit db7973e)
1 of 5 tasks
agneszitte
approved these changes
Oct 27, 2026
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Merged
1 task done
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.
GitHub Issue: closes #24224
PR Type:
🔄 Refactoring (no functional changes, no api changes)
What changed? 🚀
ValidateDefinitionsiterateddefinitions.GetItems(), which hands back the backingDependencyObjectCollectionasIEnumerable<DefinitionBase>. ItsGetEnumeratorreturnsIEnumerator<T>, boxing theList<T>.Enumeratorstruct, and the method runs twice perGridmeasure — once for rows, once for columns.Loop by index instead.
DefinitionCollectionBasealready exposedCountandGetItem(int), andGetItemis_inner[index]— the same sequence the enumerator walks — so no new API was needed.GetItems()then had no callers left and is removed rather than left dead.Measured impact 📊
grid.full-passgrid.full-passgrid.full-passWorkload run alone in both configurations, change reverted and re-applied on the current tree, 5 runs each, median. Allocation figures byte-identical across runs.
27,280 B saved over 341 grids = 80 B per grid per pass — two boxed
List<T>.Enumerators at 40 B each, one for rows and one for columns, matching the constant measured independently inVisualTreeHelper.Validation ✅
Runtime tests, Skia Desktop — same 937-test layout/rendering/framework suite as the visual-tree PR, set-compared against a baseline build: 0 new failures, 0 newly passing.
PR Checklist ✅
Screenshots Compare Test Runresults. — to check once CI has runThis is an automatic backport of pull request #24233 done by [Mergify](https://mergify.com).