Skip to content

Commit d0d0b2b

Browse files
authored
Avoid enumerator boxing for ItemBucket (#11929)
1 parent ac0e764 commit d0d0b2b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Build.UnitTests/BackEnd/TaskExecutionHost_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ private void InitializeHost(bool throwOnExecute)
12821282
itemsByName.Add(item2);
12831283
_twoItems = new ITaskItem[] { new TaskItem(item), new TaskItem(item2) };
12841284

1285-
_bucket = new ItemBucket(Array.Empty<string>(), new Dictionary<string, string>(), new Lookup(itemsByName, new PropertyDictionary<ProjectPropertyInstance>()), 0);
1285+
_bucket = new ItemBucket(new Dictionary<string, ICollection<ProjectItemInstance>>().Keys, new Dictionary<string, string>(), new Lookup(itemsByName, new PropertyDictionary<ProjectPropertyInstance>()), 0);
12861286
_bucket.Initialize(null);
12871287
_host.FindTask(null);
12881288
_host.InitializeForBatch(talc, _bucket, null);

src/Build/BackEnd/Components/RequestBuilder/ItemBucket.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private ItemBucket(Dictionary<string, string> metadata)
7474
/// <param name="lookup">The <see cref="Lookup"/> to use for the items in the bucket.</param>
7575
/// <param name="bucketSequenceNumber">A sequence number indication what order the buckets were created in.</param>
7676
internal ItemBucket(
77-
ICollection<string> itemNames,
77+
Dictionary<string, ICollection<ProjectItemInstance>>.KeyCollection itemNames, // PERF: directly use the KeyCollection to avoid boxing the enumerator.
7878
Dictionary<string, string> metadata,
7979
Lookup lookup,
8080
int bucketSequenceNumber)

0 commit comments

Comments
 (0)