-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pool incrementalHash so that we don't create one unnecessarily #33496
Conversation
@@ -14,41 +15,44 @@ namespace Microsoft.CodeAnalysis | |||
// all these are just helper methods | |||
internal partial class Checksum | |||
{ | |||
private static readonly ObjectPool<IncrementalHash> s_objectPool = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Consider using a more specific name for this pool field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
tagging @dotnet/roslyn-ide |
@@ -14,41 +15,44 @@ namespace Microsoft.CodeAnalysis | |||
// all these are just helper methods | |||
internal partial class Checksum | |||
{ | |||
private static readonly ObjectPool<IncrementalHash> s_incrementalHashPool = | |||
new ObjectPool<IncrementalHash>(() => IncrementalHash.CreateHash(HashAlgorithmName.SHA1), size: 20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 20?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no particular reason. other pool uses 20 so, it uses 20 as well.
stream.Seek(0, SeekOrigin.Begin); | ||
stream.Seek(0, SeekOrigin.Begin); | ||
|
||
var hash = pooledHash.Object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does anything need to reset this, either before/after using it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hash got reset when it get into the pool
save cost of creating new incremental hash.