[Xamarin.Android.Build.Tasks] simplify LINQ in ResolveAssemblies #2168
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.
Looking at
ResolveAssemblies, I noticed a lot of LINQ usage thatcould be simplified.
We were using
HashSet<string>that contains a list of allassemblies, and the following code:
This was called from a recursive function and needlessly calls
new AssemblyNameDefinition ().Namefor every other assembly...Roughly a O(N^2) operation.
So I changed the
HashSet<string>to be aDictionary<string, string>, where the "key" is theassembly.Name.Nameand the valuethe full path to the assembly.
I also fixed up usage of
assembly.MainModule.FullyQualifiedName,which was deprecated mentioning to use
FileNameinstead.Lastly, I fixed up several LINQ expressions on the
OutputsofResolveAssemblies. I rewrote them to use a singleforeachloopinstead of the equivalent LINQ that would loop over the list multiple
times.
Results
The build time improvements here were "not zero", but also not huge.
Testing the
tests/Xamarin.Forms-Performance-Integrationproject, abuild with no changes...
Before:
After:
I think this change is still worthwhile, since:
and I plan to refactor this task more soon.
changes.
Other changes: