Skip to content

Commit 35b0ce8

Browse files
jpobstjonpryor
authored andcommitted
[generator] Use an ILookup for better performance. (#440)
Using an `ILookup` instead of constantly recalculating and iterating over the `IEnumerable` returned by `FlattenGens()` causes the `ApiVersionsSupport.AssignApiLevels()` step duration to drop while generating `Mono.Android.dll` from ~30s to ~0.3s.
1 parent a3b7456 commit 35b0ce8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/generator/ApiVersionsSupport.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ static IEnumerable<GenBase> FlattenGens (IEnumerable<GenBase> gens)
3131

3232
public static void AssignApiLevels (IList<GenBase> gens, string apiVersionsXml)
3333
{
34-
var flattenGens = FlattenGens (gens);
34+
var flattenGens = FlattenGens (gens).ToLookup (g => g.JavaName);
3535
var versions = new ApiVersionsProvider ();
3636
versions.Parse (apiVersionsXml);
3737
foreach (var type in versions.Versions.Values) {
38-
var matchedGens = flattenGens.Where (g => g.JavaName == type.Name);
38+
var matchedGens = flattenGens [type.Name];
3939
if (!matchedGens.Any ())
4040
// There are known missing types, and it's going to be too noisy to report missing ones here.
4141
// That task should be done elsewhere.

0 commit comments

Comments
 (0)