Skip to content

Commit b159d91

Browse files
FixedSizeBuilder.AddRange: Fix logic error
1 parent 27bbf3e commit b159d91

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/TagHelperCollection.FixedSizeBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void AddRange(TagHelperCollection collection)
5959
{
6060
foreach (var item in collection)
6161
{
62-
if (!_set.Add(item.Checksum))
62+
if (_set.Add(item.Checksum))
6363
{
6464
AppendItem(item);
6565
}
@@ -71,7 +71,7 @@ public void AddRange(ReadOnlySpan<TagHelperDescriptor> span)
7171
{
7272
foreach (var item in span)
7373
{
74-
if (!_set.Add(item.Checksum))
74+
if (_set.Add(item.Checksum))
7575
{
7676
AppendItem(item);
7777
}
@@ -83,7 +83,7 @@ public void AddRange(IEnumerable<TagHelperDescriptor> source)
8383
{
8484
foreach (var item in source)
8585
{
86-
if (!_set.Add(item.Checksum))
86+
if (_set.Add(item.Checksum))
8787
{
8888
AppendItem(item);
8989
}

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/TagHelperCollection_Factories.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
@@ -43,10 +43,7 @@ static TagHelperCollection BuildCollection(ReadOnlySpan<TagHelperDescriptor> spa
4343
{
4444
using var builder = new FixedSizeBuilder(span.Length);
4545

46-
foreach (var item in span)
47-
{
48-
builder.Add(item);
49-
}
46+
builder.AddRange(span);
5047

5148
return builder.ToCollection();
5249
}

0 commit comments

Comments
 (0)