Skip to content

Commit

Permalink
Follow up with feedback and avoid extra work when there is only one t…
Browse files Browse the repository at this point in the history
…arget
  • Loading branch information
abpiskunov authored and srivatsn committed Apr 26, 2017
1 parent 5d38fa9 commit 6ca35d0
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private void AddDependenciesToTheWorld(Dictionary<string, ItemMetadata> items,

var currentPackageUniqueId = $"{parentTargetId}/{currentItemId}";
// add current package to dependencies world
var currentItem = items[currentItemId].Clone();
var currentItem = GetItem(items, currentItemId);
DependenciesWorld[currentPackageUniqueId] = currentItem;

// update parent
Expand All @@ -255,11 +255,11 @@ private void AddDependenciesToTheWorld(Dictionary<string, ItemMetadata> items,
// Update parent's Dependencies count and make sure parent is in the dependencies world
if (!string.IsNullOrEmpty(parentPackageId))
{
parentDependency = Packages[parentPackageId].Clone();
parentDependency = GetItem(Packages, parentPackageId);
}
else
{
parentDependency = Targets[parentTargetId].Clone();
parentDependency = GetItem(Targets, parentTargetId);
currentItem.IsTopLevelDependency = true;
}

Expand All @@ -269,6 +269,11 @@ private void AddDependenciesToTheWorld(Dictionary<string, ItemMetadata> items,
}
}

private ItemMetadata GetItem(Dictionary<string, ItemMetadata> items, string id)
{
return Targets.Count > 1 ? items[id].Clone() : items[id];
}

private abstract class ItemMetadata
{
public ItemMetadata(DependencyType type, IList<string> dependencies = null, bool isTopLevelDependency = false)
Expand Down

0 comments on commit 6ca35d0

Please sign in to comment.