Skip to content

Commit 9110278

Browse files
Update DictionaryJumpTable.cs with FrozenDictionary (#49714)
1 parent 26d6e37 commit 9110278

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Http/Routing/src/Matching/DictionaryJumpTable.cs

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

4+
using System.Collections.Frozen;
45
using System.Linq;
56
using System.Text;
67

@@ -10,7 +11,7 @@ internal sealed class DictionaryJumpTable : JumpTable
1011
{
1112
private readonly int _defaultDestination;
1213
private readonly int _exitDestination;
13-
private readonly Dictionary<string, int> _dictionary;
14+
private readonly FrozenDictionary<string, int> _dictionary;
1415

1516
public DictionaryJumpTable(
1617
int defaultDestination,
@@ -20,11 +21,7 @@ public DictionaryJumpTable(
2021
_defaultDestination = defaultDestination;
2122
_exitDestination = exitDestination;
2223

23-
_dictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
24-
for (var i = 0; i < entries.Length; i++)
25-
{
26-
_dictionary.Add(entries[i].text, entries[i].destination);
27-
}
24+
_dictionary = entries.ToFrozenDictionary(e => e.text, e => e.destination, StringComparer.OrdinalIgnoreCase);
2825
}
2926

3027
public override int GetDestination(string path, PathSegment segment)

0 commit comments

Comments
 (0)