Open martincostello opened 3 months ago
Thanks for the PR! Is this optimization addressing a performance problem you're seeing in practice? Regardless, this seems like a good thing to do, but merging it into main would mean it won't be available until 7.1 releases (probably December/January).
Is this optimization addressing a performance problem you're seeing in practice?
No, just something I stumbled across when looking at the code.
Okay thanks. I want to think a bit more about GetHashAlgorithmForSigningAlgorithm (maybe we deprecate it), but this looks great! For now I'll leave this open as a reminder.
Use
SHA*.HashData()
one-shot methods to avoid allocatingSHA*
objects.This is something I just happened to notice while I was debugging an issue in something using IdentityServer in a sample and I stepped into the decompiled code.
The only usages of
SHA*.Create()
left after this change are these:https://github.com/DuendeSoftware/IdentityServer/blob/e9860c6488f90e8fbc11a4452b9dd111dbfae933/src/IdentityServer/Configuration/CryptoHelper.cs#L84-L100
As this is a public method I left it as-is, but refactored the only caller within the codebase itself to use the one-shot methods and not depend on it anymore.