Skip to content

Commit f5a0926

Browse files
committed
Removed unnecessary allocations
1 parent 9348e90 commit f5a0926

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

DnsServerCore/Dns/Security/DnsCookieSecretManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,19 @@ public void Rotate()
180180
}
181181

182182
// Returning spans here is unsafe once the lock is released; return a clone instead.
183-
public byte[] GetCurrentSecret()
183+
public ReadOnlySpan<byte> GetCurrentSecret()
184184
{
185185
lock (_lock)
186186
{
187-
return _currentSecret is null ? null : (byte[])_currentSecret.Clone();
187+
return _currentSecret is null ? null : new ReadOnlySpan<byte>(_currentSecret);
188188
}
189189
}
190190

191-
public byte[] GetPreviousSecret()
191+
public ReadOnlySpan<byte> GetPreviousSecret()
192192
{
193193
lock (_lock)
194194
{
195-
return _previousSecret is null ? null : (byte[])_previousSecret.Clone();
195+
return _previousSecret is null ? null : new ReadOnlySpan<byte>(_previousSecret);
196196
}
197197
}
198198

0 commit comments

Comments
 (0)