Avoid O(n²) array growth in GenerateTypeMappings#11127
Conversation
Replace Concat().ToArray() per-arch iteration with a backing List<ITaskItem> field that uses AddRange(), converting to array once at the end of RunTask(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add items directly to the backing List<ITaskItem> field instead of building a local list and calling AddRange(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves performance in the GenerateTypeMappings MSBuild task by eliminating repeated Concat().ToArray() calls that caused O(n²) copying as typemap outputs were accumulated across architectures.
Changes:
- Replace per-architecture array concatenation with a single backing
List<ITaskItem>for generated typemap outputs. - Emit the MSBuild
[Output]ITaskItem[]once at the end ofRunTask()via a singleToArray()call.
jonathanpeppers
left a comment
There was a problem hiding this comment.
🤖 AI Review Summary
Verdict:
Found 0 errors, 0 warnings, 1 suggestion:
- 💡 Formatting: Minor style nit —
new List<ITaskItem> ()→[]for consistency (GenerateTypeMappings.cs:53)
CI Note: All public checks pass ✅, but the internal Xamarin.Android-PR pipeline is failing — may need a re-run.
👍 Clean fix. The old Concat().ToArray() pattern copied the entire array on every architecture iteration — classic O(n²) growth. Replacing it with a backing List<ITaskItem> and a single .ToArray() at the end is the right call.
Review generated by android-reviewer from review guidelines.
|
There is only a WearOS emulator issue -- merging. |
Description
GenerateTypeMappings.AddOutputTypeMaps()calledConcat().ToArray()onGeneratedBinaryTypeMapsfor each architecture iteration, copying the entire array each time -- O(n²) growth.This replaces that pattern with a backing
List<ITaskItem>field that items are added to directly, with a single.ToArray()call at the end ofRunTask()to satisfy the MSBuild[Output]property type requirement.