Skip to content

Commit ec0ae43

Browse files
authored
Initialize list count in CreateClaims (#2596)
This reduces how many internal array allocations need to happen for each claim set. In my benchmark I have 17 claims, which is kind of a worst case scenario because it starts at 4 and doubles to 32 before the list is big enough.
1 parent a1530a0 commit ec0ae43

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonClaimSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ internal List<Claim> Claims(string issuer)
4444

4545
internal List<Claim> CreateClaims(string issuer)
4646
{
47-
var claims = new List<Claim>();
47+
var claims = new List<Claim>(_jsonClaims.Count);
4848
foreach (KeyValuePair<string, object> kvp in _jsonClaims)
4949
CreateClaimFromObject(claims, kvp.Key, kvp.Value, issuer);
5050

0 commit comments

Comments
 (0)