4
4
using System ;
5
5
using System . Collections . Generic ;
6
6
using System . Diagnostics ;
7
- using System . Runtime . CompilerServices ;
8
7
using Microsoft . AspNetCore . Components . RenderTree ;
9
8
10
9
namespace Microsoft . AspNetCore . Components . Rendering
@@ -27,7 +26,7 @@ public sealed class RenderTreeBuilder : IDisposable
27
26
private readonly Stack < int > _openElementIndices = new Stack < int > ( ) ;
28
27
private RenderTreeFrameType ? _lastNonAttributeFrameType ;
29
28
private bool _hasSeenAddMultipleAttributes ;
30
- private MultipleAttributesDictionary ? _seenAttributeNames ;
29
+ private Dictionary < string , int > ? _seenAttributeNames ;
31
30
32
31
/// <summary>
33
32
/// The reserved parameter name used for supplying child content.
@@ -707,21 +706,22 @@ internal void ProcessDuplicateAttributes(int first)
707
706
}
708
707
709
708
// Now that we've found the last attribute, we can iterate backwards and process duplicates.
710
- var seenAttributeNames = ( _seenAttributeNames ??= new MultipleAttributesDictionary ( ) ) ;
709
+ var seenAttributeNames = ( _seenAttributeNames ??= new Dictionary < string , int > ( SimplifiedStringHashComparer . Instance ) ) ;
711
710
for ( var i = last ; i >= first ; i -- )
712
711
{
713
712
ref var frame = ref buffer [ i ] ;
714
713
Debug . Assert ( frame . FrameTypeField == RenderTreeFrameType . Attribute , $ "Frame type is { frame . FrameTypeField } at { i } ") ;
715
714
716
- if ( ! seenAttributeNames . TryAdd ( frame . AttributeNameField , i , out var index ) )
715
+ if ( ! seenAttributeNames . TryAdd ( frame . AttributeNameField , i ) )
717
716
{
717
+ var index = seenAttributeNames [ frame . AttributeNameField ] ;
718
718
if ( index < i )
719
719
{
720
720
// This attribute is overriding a "silent frame" where we didn't create a frame for an AddAttribute call.
721
721
// This is the case for a null event handler, or bool false value.
722
722
//
723
723
// We need to update our tracking, in case the attribute appeared 3 or more times.
724
- seenAttributeNames . Replace ( frame . AttributeNameField , i ) ;
724
+ seenAttributeNames [ frame . AttributeNameField ] = i ;
725
725
}
726
726
else if ( index > i )
727
727
{
@@ -778,8 +778,8 @@ internal void TrackAttributeName(string name)
778
778
return ;
779
779
}
780
780
781
- var seenAttributeNames = ( _seenAttributeNames ??= new MultipleAttributesDictionary ( ) ) ;
782
- seenAttributeNames . TryAdd ( name , _entries . Count , out _ ) ; // See comment in ProcessAttributes for why this is OK.
781
+ var seenAttributeNames = ( _seenAttributeNames ??= new Dictionary < string , int > ( SimplifiedStringHashComparer . Instance ) ) ;
782
+ seenAttributeNames [ name ] = _entries . Count ; // See comment in ProcessAttributes for why this is OK.
783
783
}
784
784
785
785
void IDisposable . Dispose ( )
0 commit comments