Skip to content

Commit

Permalink
[XABT] Replace SortedSet with HashSet. (#9280)
Browse files Browse the repository at this point in the history
One question that came up with #9208 was "why `SortedSet` instead of `HashSet`"?

Indeed a `HashSet` seems to be 10ms - 15ms faster to construct than the `SortedSet` while taking the same ~1ms to perform the `SetEquals` operation.
  • Loading branch information
jpobst authored Sep 4, 2024
1 parent aeeb51a commit d6213d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Utilities/JCWGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ static void EnsureIdenticalCollections (TaskLoggingHelper logger, NativeCodeGenS
{
logger.LogDebugMessage ($"Ensuring Java type collection in architecture '{state.TargetArch}' matches the one in architecture '{templateState.TargetArch}'");

var templateSet = new SortedSet<string> (templateState.AllJavaTypes.Select (t => t.FullName), StringComparer.Ordinal);
var typesSet = new SortedSet<string> (state.AllJavaTypes.Select (t => t.FullName), StringComparer.Ordinal);
var templateSet = new HashSet<string> (templateState.AllJavaTypes.Select (t => t.FullName), StringComparer.Ordinal);
var typesSet = new HashSet<string> (state.AllJavaTypes.Select (t => t.FullName), StringComparer.Ordinal);

if (typesSet.Count != templateSet.Count) {
throw new InvalidOperationException ($"Internal error: architecture '{state.TargetArch}' has a different number of types ({typesSet.Count}) than the template architecture '{templateState.TargetArch}' ({templateSet.Count})");
Expand Down

0 comments on commit d6213d5

Please sign in to comment.