Skip to content

Commit

Permalink
Merge branch 'jsp/optimize-getresolvedprojects' into 'main'
Browse files Browse the repository at this point in the history
Optimized Solution.GetResolvedProjects()

See merge request Sharpmake/sharpmake!581
  • Loading branch information
jspelletier committed Nov 13, 2024
2 parents 2e97f16 + 87e3de7 commit 88e2c86
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Sharpmake/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class ResolvedProject
public string ProjectFile;

// Resolved Project dependencies
public List<ResolvedProject> Dependencies = new List<ResolvedProject>();
public HashSet<ResolvedProject> Dependencies = new HashSet<ResolvedProject>();

// User data, may be use by generator to attach user data
public Dictionary<string, object> UserData = new Dictionary<string, object>();
Expand Down Expand Up @@ -191,8 +191,7 @@ public IEnumerable<ResolvedProject> GetResolvedProjects(IEnumerable<Configuratio
resolvedProject.Configurations.Add(includedProjectInfo.Configuration);
resolvedProject.SolutionConfigurationsBuild.Add(solutionConfiguration, includedProjectInfo.ToBuild);

if (!configurationsToProjects.ContainsKey(includedProjectInfo.Configuration))
configurationsToProjects[includedProjectInfo.Configuration] = resolvedProject;
configurationsToProjects.TryAdd(includedProjectInfo.Configuration, resolvedProject);
}
}

Expand All @@ -219,12 +218,11 @@ public IEnumerable<ResolvedProject> GetResolvedProjects(IEnumerable<Configuratio

foreach (Project.Configuration dependencyConfiguration in resolvedProjectConf.ResolvedDependencies)
{
if (configurationsToProjects.ContainsKey(dependencyConfiguration))
{
var resolvedProjectToAdd = configurationsToProjects[dependencyConfiguration];
ResolvedProject resolvedProjectToAdd;

if (!resolvedProject.Dependencies.Contains(resolvedProjectToAdd))
resolvedProject.Dependencies.Add(resolvedProjectToAdd);
if (configurationsToProjects.TryGetValue(dependencyConfiguration, out resolvedProjectToAdd))
{
resolvedProject.Dependencies.Add(resolvedProjectToAdd);
}
}
}
Expand Down

0 comments on commit 88e2c86

Please sign in to comment.