Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Switch ConditionedPropertyCollection to use ImmutableArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Therzok authored and monojenkins committed Jan 15, 2020
1 parent b97a6f0 commit 6dde048
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace MonoDevelop.Projects
{
public class ConditionedPropertyCollection
{
Dictionary<string, ImmutableList<string>> props = new Dictionary<string, ImmutableList<string>> ();
Dictionary<KeySet, ImmutableList<ValueSet>> combinedProps = new Dictionary<KeySet, ImmutableList<ValueSet>> (StructEqualityComparer<KeySet>.Instance);
Dictionary<string, ImmutableArray<string>> props = new Dictionary<string, ImmutableArray<string>> ();
Dictionary<KeySet, ImmutableArray<ValueSet>> combinedProps = new Dictionary<KeySet, ImmutableArray<ValueSet>> (StructEqualityComparer<KeySet>.Instance);

/// <summary>
/// A set of strings, which can be compared to other sets ignoring the order.
Expand Down Expand Up @@ -178,22 +178,22 @@ internal void Append (ConditionedPropertyCollection other)
foreach (var e in other.props) {
var otherList = e.Value;
var key = e.Key;
ImmutableList<string> list;
ImmutableArray<string> list;
if (props.TryGetValue (key, out list)) {
var lb = list.ToBuilder ();
foreach (var c in otherList) {
if (!lb.Contains (c))
lb.Add (c);
}
props [key] = lb.ToImmutableList ();
props [key] = lb.ToImmutable ();
} else
props [key] = otherList;
}

foreach (var e in other.combinedProps) {
var otherList = e.Value;
var key = e.Key;
ImmutableList<ValueSet> thisList;
ImmutableArray<ValueSet> thisList;
if (combinedProps.TryGetValue (key, out thisList)) {
var list = thisList.ToBuilder ();
foreach (var c in otherList) {
Expand All @@ -210,13 +210,13 @@ internal void Append (ConditionedPropertyCollection other)
internal void AddPropertyValues (IList<string> names, IList<string> values)
{
var key = new KeySet (names);
ImmutableList<ValueSet> list;
ImmutableArray<ValueSet> list;
ValueSet valueSet;

// First register the combination of values

if (!combinedProps.TryGetValue (key, out list)) {
list = ImmutableList<ValueSet>.Empty;
list = ImmutableArray<ValueSet>.Empty;
valueSet = new ValueSet (names, names, values);
} else {
// If there is already a list, there must be at least one item.
Expand All @@ -229,12 +229,12 @@ internal void AddPropertyValues (IList<string> names, IList<string> values)

// Now register each value individually

ImmutableList<string> valList;
ImmutableArray<string> valList;
for (int n = 0; n < names.Count; n++) {
var name = names [n];
var val = values [n];
if (!props.TryGetValue (name, out valList))
valList = ImmutableList<string>.Empty;
valList = ImmutableArray<string>.Empty;
if (!valList.Contains (val))
props[name] = valList.Add (val);
}
Expand All @@ -252,12 +252,12 @@ public IEnumerable<string> GetAllProperties ()
/// <summary>
/// Gets the values used in conditions for the given property
/// </summary>
public ImmutableList<string> GetAllPropertyValues (string property)
public ImmutableArray<string> GetAllPropertyValues (string property)
{
ImmutableList<string> list;
ImmutableArray<string> list;
if (props.TryGetValue (property, out list))
return list;
return ImmutableList<string>.Empty;
return ImmutableArray<string>.Empty;
}

/// <summary>
Expand All @@ -266,12 +266,12 @@ public ImmutableList<string> GetAllPropertyValues (string property)
/// Platform, it will return values for those properties specified in conditions that reference both
/// Configuration and Platform.
/// </summary>
public ImmutableList<ValueSet> GetCombinedPropertyValues (params string[] properties)
public ImmutableArray<ValueSet> GetCombinedPropertyValues (params string[] properties)
{
ImmutableList<ValueSet> list;
ImmutableArray<ValueSet> list;
if (combinedProps.TryGetValue (new KeySet (properties), out list))
return list;
return ImmutableList<ValueSet>.Empty;
return ImmutableArray<ValueSet>.Empty;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2971,7 +2971,7 @@ List<ConfigData> GetConfigData (MSBuildProject msproject, bool includeEvaluated)
// Now add configurations for which a platform has not been specified, but only if no other configuration
// exists with the same name. Combine them with individually specified platforms, if available
foreach (var c in confValues.Select (v => v.GetValue ("Configuration"))) {
if (platValues.Count > 0) {
if (platValues.Length > 0) {
foreach (var plat in platValues.Select (v => v.GetValue ("Platform"))) {
var ep = plat == "AnyCPU" ? "" : plat;
if (!configData.Any (cd => cd.Config == c && cd.Platform == ep))
Expand Down

0 comments on commit 6dde048

Please sign in to comment.