[#39] Client: add memory usage optimizations
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
d6fe034453
commit
32a7e64538
14 changed files with 120 additions and 92 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
|
||||
using CommunityToolkit.HighPerformance;
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
|
||||
namespace FrostFS.SDK.Cryptography;
|
||||
|
@ -35,7 +36,27 @@ public static class Extentions
|
|||
finally
|
||||
{
|
||||
if (lockTaken)
|
||||
{
|
||||
_spinlockSha256.Exit(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Sha256(this ReadOnlyMemory<byte> value)
|
||||
{
|
||||
bool lockTaken = false;
|
||||
try
|
||||
{
|
||||
_spinlockSha256.Enter(ref lockTaken);
|
||||
|
||||
return _sha256.ComputeHash(value.AsStream());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lockTaken)
|
||||
{
|
||||
_spinlockSha256.Exit(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue